Permalink
Browse files

Fix symbolication failure caused by attempt to modify frozen frame

Summary:
This change makes so that processing stack trace before sending it to packager (see 7dbc805)
doesn't modify original frames but creates a copies instead.

This is required because after some changes that also have been landed in 0.35, frames that arrive to
'symbolicateStackTrace' are already frozen, so changing 'file' property of the original frame causes
symbolication to fail.
Closes #10655

Differential Revision: D4110273

fbshipit-source-id: 0302694b520d83a79c3cb67903038b3f494315f2
  • Loading branch information...
1 parent cdd2d79 commit 0fe1c7a9ff84bb0d49a0fbe3de3d09d89bf1a785 @ide ide committed with Facebook Github Bot Nov 1, 2016
Showing with 17 additions and 6 deletions.
  1. +17 −6 Libraries/Core/Devtools/symbolicateStackTrace.js
@@ -18,27 +18,38 @@ const {fetch} = require('fetch');
import type {StackFrame} from 'parseErrorStack';
+function isSourcedFromDisk(sourcePath: string): boolean {
+ return !/^http/.test(sourcePath) && /[\\/]/.test(sourcePath);
+}
+
async function symbolicateStackTrace(stack: Array<StackFrame>): Promise<Array<StackFrame>> {
const devServer = getDevServer();
if (!devServer.bundleLoadedFromServer) {
throw new Error('Bundle was not loaded from the packager');
}
+
+ let stackCopy = stack;
+
if (SourceCode.scriptURL) {
- for (let i = 0; i < stack.length; ++i) {
+ let foundInternalSource: boolean = false;
+ stackCopy = stack.map((frame: StackFrame) => {
// If the sources exist on disk rather than appearing to come from the packager,
// replace the location with the packager URL until we reach an internal source
// which does not have a path (no slashes), indicating a switch from within
// the application to a surrounding debugging environment.
- if (/^http/.test(stack[i].file) || !/[\\/]/.test(stack[i].file)) {
- break;
+ if (!foundInternalSource && isSourcedFromDisk(frame.file)) {
+ // Copy frame into new object and replace 'file' property
+ return {...frame, file: SourceCode.scriptURL};
}
- stack[i].file = SourceCode.scriptURL;
- }
+
+ foundInternalSource = true;
+ return frame;
+ });
}
const response = await fetch(devServer.url + 'symbolicate', {
method: 'POST',
- body: JSON.stringify({stack}),
+ body: JSON.stringify({stack: stackCopy}),
});
const json = await response.json();
return json.stack;

0 comments on commit 0fe1c7a

Please sign in to comment.