Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit d6ddb75

Browse files
authored
Increase Bridge serialization threshold from 1 -> 2 (#1263)
Increase Bridge serialization threshold from 1 -> 2 This is being done to fix interaction names within the Profiler.
1 parent 4d30604 commit d6ddb75

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

agent/__tests__/dehydrate-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ describe('dehydrate', () => {
3333
var object = {a: {b: {c: {d: 4}}}};
3434
var cleaned = [];
3535
var result = dehydrate(object, cleaned);
36-
expect(cleaned).toEqual([['a', 'b']]);
37-
expect(result.a.b).toEqual({type: 'object', name: '', meta: {}});
38-
expect(result.a.b.c).toBeUndefined(); // Dehydrated
36+
expect(cleaned).toEqual([['a', 'b', 'c']]);
37+
expect(result.a.b.c).toEqual({type: 'object', name: '', meta: {}});
38+
expect(result.a.b.c.d).toBeUndefined(); // Dehydrated
3939

4040
// Re-hydrate
41-
result.a.b = dehydrate(object.a.b, [], ['a', 'b']);
41+
result.a.b.c = dehydrate(object.a.b.c, [], ['a', 'b', 'c']);
4242
expect(result).toEqual(object);
4343
});
4444

4545
it('cleans a deeply nested array', () => {
46-
var object = {a: {b: [1, 3]}};
46+
var object = {a: {b: {c: [1, 3]}}};
4747
var cleaned = [];
4848
var result = dehydrate(object, cleaned);
49-
expect(cleaned).toEqual([['a', 'b']]);
50-
expect(result.a.b).toEqual({type: 'array', name: 'Array', meta: {length: 2}});
49+
expect(cleaned).toEqual([['a', 'b', 'c']]);
50+
expect(result.a.b.c).toEqual({type: 'array', name: 'Array', meta: {length: 2}});
5151
});
5252

5353
it('cleans multiple things', () => {
5454
var Something = function() {};
55-
var object = {a: {b: [1, 3], c: new Something()}};
55+
var object = {a: {b: {c: [1, 3], d: new Something()}}};
5656
var cleaned = [];
5757
var result = dehydrate(object, cleaned);
58-
expect(cleaned).toEqual([['a', 'b'], ['a', 'c']]);
59-
expect(result.a.b).toEqual({type: 'array', name: 'Array', meta: {length: 2}});
60-
expect(result.a.c).toEqual({type: 'object', name: 'Something', meta: {}});
58+
expect(cleaned).toEqual([['a', 'b', 'c'], ['a', 'b', 'd']]);
59+
expect(result.a.b.c).toEqual({type: 'array', name: 'Array', meta: {length: 2}});
60+
expect(result.a.b.d).toEqual({type: 'object', name: 'Something', meta: {}});
6161
});
6262

6363
it('returns readable name for dates', () => {

agent/dehydrate.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
// This threshold determines the depth at which the bridge "dehydrates" nested data.
1414
// Dehydration means that we don't serialize the data for e.g. postMessage or stringify,
1515
// unless the frontend explicitly requests it (e.g. a user clicks to expand a props object).
16-
// This value was originally set to 2, but we reduced it to improve performance:
17-
// see https://github.com/facebook/react-devtools/issues/1200
18-
// Note this value also indirectly determines how far props can be drilled into within the Profiler.
19-
const LEVEL_THRESHOLD = 1;
16+
// We tried reducing this value from 2 to 1 to improve performance:
17+
// https://github.com/facebook/react-devtools/issues/1200
18+
// But this caused problems with the Profiler's interaction tracing output.
19+
// Because React mutates Fibers, profiling data that is dehydrated for old commits–
20+
// will not be available later from within the Profiler.
21+
// This impacts props/state as well as Interactions.
22+
// https://github.com/facebook/react-devtools/issues/1262
23+
const LEVEL_THRESHOLD = 2;
2024

2125
/**
2226
* Get a enhanced/artificial type string based on the object instance

0 commit comments

Comments
 (0)