mirror of https://github.com/status-im/metro.git
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
a4c9a2d0a6
commit
9497520963
|
@ -137,7 +137,7 @@ describe('processRequest', () => {
|
|||
requestHandler,
|
||||
'index.ios.includeRequire.bundle'
|
||||
).then(response => {
|
||||
expect(response.body).toEqual('this is the source')
|
||||
expect(response.body).toEqual('this is the source');
|
||||
expect(Bundler.prototype.bundle).toBeCalledWith({
|
||||
entryFile: 'index.ios.js',
|
||||
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', () => {
|
||||
|
|
|
@ -362,7 +362,7 @@ class Server {
|
|||
e => {
|
||||
res.writeHead(500);
|
||||
res.end('Internal Error');
|
||||
console.log(e.stack);
|
||||
console.log(e.stack); // eslint-disable-line no-console-disallow
|
||||
}
|
||||
);
|
||||
} else if (parts[1] === 'graph'){
|
||||
|
@ -491,24 +491,37 @@ class Server {
|
|||
|
||||
// In case of multiple bundles / HMR, some stack frames can have
|
||||
// different URLs from others
|
||||
const urls = stack.map(frame => frame.file);
|
||||
const uniqueUrls = urls.filter((elem, idx) => urls.indexOf(elem) === idx);
|
||||
const urlIndexes = {};
|
||||
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 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 original = consumer.originalPositionFor({
|
||||
line: frame.lineNumber,
|
||||
column: frame.column,
|
||||
});
|
||||
|
||||
if (!original) {
|
||||
return frame;
|
||||
}
|
||||
|
||||
return Object.assign({}, frame, {
|
||||
file: original.source,
|
||||
lineNumber: original.line,
|
||||
|
|
Loading…
Reference in New Issue