mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
RN: Fix Symbolicate Logspew for /debuggerWorker.js
Summary: When remote debugging is enabled, stack traces start at `/debuggerWorker.js`. Since this is not a valid bundle URL, the packager fails to decipher it to find its sourcemap. This changes the packager to skip the `/debuggerWorker.js` stack frame if one exists. Reviewed By: frantic Differential Revision: D3418341 fbshipit-source-id: 7434aa45dea7d120d9d77c060101dd9403989d0c
This commit is contained in:
parent
0d572e40f0
commit
5e73c070e8
@ -137,7 +137,7 @@ describe('processRequest', () => {
|
|||||||
requestHandler,
|
requestHandler,
|
||||||
'index.ios.includeRequire.bundle'
|
'index.ios.includeRequire.bundle'
|
||||||
).then(response => {
|
).then(response => {
|
||||||
expect(response.body).toEqual('this is the source')
|
expect(response.body).toEqual('this is the source');
|
||||||
expect(Bundler.prototype.bundle).toBeCalledWith({
|
expect(Bundler.prototype.bundle).toBeCalledWith({
|
||||||
entryFile: 'index.ios.js',
|
entryFile: 'index.ios.js',
|
||||||
inlineSourceMap: false,
|
inlineSourceMap: false,
|
||||||
@ -429,6 +429,28 @@ describe('processRequest', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pit('ignores `/debuggerWorker.js` stack frames', () => {
|
||||||
|
const body = JSON.stringify({stack: [{
|
||||||
|
file: 'http://localhost:8081/debuggerWorker.js',
|
||||||
|
lineNumber: 123,
|
||||||
|
column: 456,
|
||||||
|
}]});
|
||||||
|
|
||||||
|
return makeRequest(
|
||||||
|
requestHandler,
|
||||||
|
'/symbolicate',
|
||||||
|
{ rawBody: body }
|
||||||
|
).then(response => {
|
||||||
|
expect(JSON.parse(response.body)).toEqual({
|
||||||
|
stack: [{
|
||||||
|
file: 'http://localhost:8081/debuggerWorker.js',
|
||||||
|
lineNumber: 123,
|
||||||
|
column: 456,
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/symbolicate handles errors', () => {
|
describe('/symbolicate handles errors', () => {
|
||||||
|
29
packager/react-packager/src/Server/index.js
vendored
29
packager/react-packager/src/Server/index.js
vendored
@ -362,7 +362,7 @@ class Server {
|
|||||||
e => {
|
e => {
|
||||||
res.writeHead(500);
|
res.writeHead(500);
|
||||||
res.end('Internal Error');
|
res.end('Internal Error');
|
||||||
console.log(e.stack);
|
console.log(e.stack); // eslint-disable-line no-console-disallow
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (parts[1] === 'graph'){
|
} else if (parts[1] === 'graph'){
|
||||||
@ -491,24 +491,37 @@ class Server {
|
|||||||
|
|
||||||
// In case of multiple bundles / HMR, some stack frames can have
|
// In case of multiple bundles / HMR, some stack frames can have
|
||||||
// different URLs from others
|
// different URLs from others
|
||||||
const urls = stack.map(frame => frame.file);
|
const urlIndexes = {};
|
||||||
const uniqueUrls = urls.filter((elem, idx) => urls.indexOf(elem) === idx);
|
const uniqueUrls = [];
|
||||||
|
stack.forEach(frame => {
|
||||||
|
const sourceUrl = frame.file;
|
||||||
|
// Skip `/debuggerWorker.js` which drives remote debugging because it
|
||||||
|
// does not need to symbolication.
|
||||||
|
if (!urlIndexes.hasOwnProperty(sourceUrl) &&
|
||||||
|
!sourceUrl.endsWith('/debuggerWorker.js')) {
|
||||||
|
urlIndexes[sourceUrl] = uniqueUrls.length;
|
||||||
|
uniqueUrls.push(sourceUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const sourceMaps = uniqueUrls.map(sourceUrl => this._sourceMapForURL(sourceUrl));
|
const sourceMaps = uniqueUrls.map(
|
||||||
|
sourceUrl => this._sourceMapForURL(sourceUrl)
|
||||||
|
);
|
||||||
return Promise.all(sourceMaps).then(consumers => {
|
return Promise.all(sourceMaps).then(consumers => {
|
||||||
return stack.map(frame => {
|
return stack.map(frame => {
|
||||||
const idx = uniqueUrls.indexOf(frame.file);
|
const sourceUrl = frame.file;
|
||||||
|
if (!urlIndexes.hasOwnProperty(sourceUrl)) {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
const idx = urlIndexes[sourceUrl];
|
||||||
const consumer = consumers[idx];
|
const consumer = consumers[idx];
|
||||||
|
|
||||||
const original = consumer.originalPositionFor({
|
const original = consumer.originalPositionFor({
|
||||||
line: frame.lineNumber,
|
line: frame.lineNumber,
|
||||||
column: frame.column,
|
column: frame.column,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!original) {
|
if (!original) {
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.assign({}, frame, {
|
return Object.assign({}, frame, {
|
||||||
file: original.source,
|
file: original.source,
|
||||||
lineNumber: original.line,
|
lineNumber: original.line,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user