Skip to content

Commit

Permalink
Fix an error on Comet
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tyao1 authored and facebook-github-bot committed Aug 9, 2024
1 parent 57b4baf commit 234c062
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/backend/EnvironmentWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ function sanitizeEvent(event: Object): Object {
const value = event[key];
if (typeof value === 'function' || UNUSED_EXPENSIVE_FIELDS.includes(key)) {
continue;
} else if (value == null) {
newEvent[key] = value;
} else if (typeof value !== 'object') {
} else if (value == null || typeof value !== 'object') {
newEvent[key] = value;
} else if (value instanceof Map) {
newEvent[key] = Object.fromEntries((value: Map<mixed, mixed>));
Expand All @@ -60,9 +58,10 @@ function sanitizeEvent(event: Object): Object {
newEvent[key] = JSON.parse(JSON.stringify(value.toJSON()));
} else if (
(key === 'info' && event.name === 'network.info') ||
event.name === 'network.start' ||
key === 'cacheConfig'
) {
// Network info contains arbitary data
// Some network events contain arbitary data
newEvent[key] = JSON.parse(JSON.stringify(value));
} else {
newEvent[key] = value;
Expand Down

0 comments on commit 234c062

Please sign in to comment.