Skip to content

Commit 4f834e3

Browse files
committed
Add a comment to run source map symbolication on the main thread for debugging
It proved somewhat difficult when I had the debug the source map symbolication worker on the worker thread. It makes things a lot easier when it runs on the main thread instead. I tried adding a const flag for this with its proper function, but esbuild wasn't properly removing the dead code, so it was inflating the bundle a lot when this function was there even if it was unused. I tried also converting that into an async import, which extracted the symbolication into a different bundle, but it was still outputting the extra bundle even if it was false constant value. So, I decided to include it as a commented out documentation in case we need it in the future. It's not the best, but it should still help us when we need to debug the worker in the future.
1 parent 4bcf2a3 commit 4f834e3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/actions/source-map-symbolication.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,29 @@ export function doSourceMapSymbolication(
7676
* Spawn a one-shot source map worker, send it the input, and return the
7777
* output. The worker is terminated once a response is received or an error
7878
* occurs. Uses the same on-demand spawn pattern as gz.browser.ts.
79+
*
80+
* Debugging tip: to step through symbolication from the page DevTools, paste
81+
* the snippet below over this function body. It runs the same core on the
82+
* main thread (blocking, debug only).
83+
*
84+
* const { runSourceMapSymbolicationCore } = await import(
85+
* 'firefox-profiler/profile-logic/source-map-symbolication'
86+
* );
87+
* const sources = {
88+
* length: input.sources.length,
89+
* id: input.sources.id.slice(),
90+
* filename: input.sources.filename.slice(),
91+
* startLine: input.sources.startLine.slice(),
92+
* startColumn: input.sources.startColumn.slice(),
93+
* sourceMapURL: input.sources.sourceMapURL.slice(),
94+
* content: input.sources.content.slice(),
95+
* };
96+
* const stringArray = input.stringArray.slice();
97+
* const wasmUrl = new URL('/mappings.wasm', window.location.href).href;
98+
* return runSourceMapSymbolicationCore(
99+
* { ...input, sources, stringArray },
100+
* wasmUrl
101+
* );
79102
*/
80103
function _runSourceMapWorker(input: WorkerInput): Promise<WorkerOutput> {
81104
return new Promise((resolve) => {

0 commit comments

Comments
 (0)