Skip to content

Commit 234c062

Browse files
tyao1facebook-github-bot
authored andcommitted
Fix an error on Comet
Summary: Avoid postMessage error on another network event that can contain function from provided variables feature and user provided values Reviewed By: lynnshaoyu Differential Revision: D61033760 fbshipit-source-id: ac051746a0a67a7606000af6e8094b445255fe6c
1 parent 57b4baf commit 234c062

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/backend/EnvironmentWrapper.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ function sanitizeEvent(event: Object): Object {
4747
const value = event[key];
4848
if (typeof value === 'function' || UNUSED_EXPENSIVE_FIELDS.includes(key)) {
4949
continue;
50-
} else if (value == null) {
51-
newEvent[key] = value;
52-
} else if (typeof value !== 'object') {
50+
} else if (value == null || typeof value !== 'object') {
5351
newEvent[key] = value;
5452
} else if (value instanceof Map) {
5553
newEvent[key] = Object.fromEntries((value: Map<mixed, mixed>));
@@ -60,9 +58,10 @@ function sanitizeEvent(event: Object): Object {
6058
newEvent[key] = JSON.parse(JSON.stringify(value.toJSON()));
6159
} else if (
6260
(key === 'info' && event.name === 'network.info') ||
61+
event.name === 'network.start' ||
6362
key === 'cacheConfig'
6463
) {
65-
// Network info contains arbitary data
64+
// Some network events contain arbitary data
6665
newEvent[key] = JSON.parse(JSON.stringify(value));
6766
} else {
6867
newEvent[key] = value;

0 commit comments

Comments
 (0)