Skip to content

Suppress StackParser to extract source code from files during tests#177

Open
Reversean wants to merge 1 commit intomasterfrom
test/supress-stackparser-logs
Open

Suppress StackParser to extract source code from files during tests#177
Reversean wants to merge 1 commit intomasterfrom
test/supress-stackparser-logs

Conversation

@Reversean
Copy link
Copy Markdown
Member

@Reversean Reversean commented Mar 31, 2026

Catcher read backtrace from file file via StackParser.

In most test-cases we don't have this file, still StackParser tries to find it, fails and output spam logs:

[@hawk.so/javascript]: Hawk JS SDK: Can not extract source code. Please, report this issue: https://github.com/codex-team/hawk.javascript/issues/new TypeError: fetch failed
[@hawk.so/javascript]:     at node:internal/deps/undici/undici:15845:13
[@hawk.so/javascript]:     at window.fetch (/home/reversean/Dev/codex/hawk.javascript/packages/javascript/src/addons/breadcrumbs.ts:398:20) {
[@hawk.so/javascript]:   [cause]: Error: not implemented... yet...
[@hawk.so/javascript]:       at makeNetworkError (node:internal/deps/undici/undici:10147:35)
[@hawk.so/javascript]:       at schemeFetch (node:internal/deps/undici/undici:11685:34)
[@hawk.so/javascript]:       at mainFetch (node:internal/deps/undici/undici:11533:30)
[@hawk.so/javascript]:       at fetching (node:internal/deps/undici/undici:11502:7)
[@hawk.so/javascript]:       at fetch (node:internal/deps/undici/undici:11368:20)
[@hawk.so/javascript]:       at fetch (node:internal/deps/undici/undici:15843:10)
[@hawk.so/javascript]:       at fetch (node:internal/bootstrap/web/exposed-window-or-worker:83:12)
[@hawk.so/javascript]:       at window.fetch (/home/reversean/Dev/codex/hawk.javascript/packages/javascript/src/addons/breadcrumbs.ts:398:26)
[@hawk.so/javascript]:       at fetchTimer (/home/reversean/Dev/codex/hawk.javascript/packages/core/src/modules/fetch-timer.ts:19:24)
[@hawk.so/javascript]:       at StackParser.loadSourceFile (/home/reversean/Dev/codex/hawk.javascript/packages/core/src/modules/stack-parser.ts:133:41)
[@hawk.so/javascript]: }

Suggested changes mocks StackParser.parse in catcher tests which prevents trash unwanted logs.

Copy link
Copy Markdown
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug if extractSourceCode is still working.

@Reversean
Copy link
Copy Markdown
Member Author

Reversean commented Apr 22, 2026

Debug if extractSourceCode is still working.

Checked on packages/sveltekit/playground, http://localhost:4173/errors/runtime-error .

Launched in preview mode (bundled js).

For 11/12 stacktrace frames it returns null (including playground code), but managed to parse one frame, and apparently these fragments are SvelteKit bootstrap, so the final result looks like thrash

image

UPD

Anyway, on build (unbundled) it looks ok

image

Copy link
Copy Markdown
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution is ok, but we still need to find out if loadSourceFile is needed. And remove it if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants