Skip to content

Reset uncaught exception handling after startup execution#5342

Merged
danlapid merged 1 commit intocloudflare:mainfrom
mhart:mhart/reset-uncaught-flag
Feb 16, 2026
Merged

Reset uncaught exception handling after startup execution#5342
danlapid merged 1 commit intocloudflare:mainfrom
mhart:mhart/reset-uncaught-flag

Conversation

@mhart
Copy link
Copy Markdown
Contributor

@mhart mhart commented Oct 20, 2025

Fixes #5332

I've confirmed this keeps the stack for any uncaught errors during startup:

service main: Uncaught Error: wtf
  at worker.js:14:11 in recurse2
  at worker.js:9:3 in recurse1
  at worker.js:16:3 in recurse2
  at worker.js:9:3 in recurse1
  at worker.js:16:3 in recurse2
  at worker.js:9:3 in recurse1
  at worker.js:16:3 in recurse2
  at worker.js:9:3 in recurse1
  at worker.js:16:3 in recurse2
  at worker.js:9:3 in recurse1

Turning this off any earlier (eg at the end of the Script constructor) is too early:

service main: Uncaught Error: wtf
  at worker.js:14:10

I've also confirmed this improves performance of running scripts with throw patterns as per #5332

@mhart mhart requested review from a team as code owners October 20, 2025 11:40
@mhart mhart changed the title Reset uncaught exception handling after Script construction Reset uncaught exception handling after startup execution Oct 20, 2025
@kentonv
Copy link
Copy Markdown
Member

kentonv commented Dec 8, 2025

@mhart was there something more you wanted to check before this lands or should I merge it?

@mhart
Copy link
Copy Markdown
Contributor Author

mhart commented Dec 8, 2025

@mhart was there something more you wanted to check before this lands or should I merge it?

Ah yeah good point, this slipped off my radar, will look again today

@kentonv
Copy link
Copy Markdown
Member

kentonv commented Feb 12, 2026

@mhart ping

@mhart mhart force-pushed the mhart/reset-uncaught-flag branch from 7fa7a7f to d079381 Compare February 16, 2026 04:59
@mhart
Copy link
Copy Markdown
Contributor Author

mhart commented Feb 16, 2026

Have played around with this a bunch now including with debug profiler sessions, as well as via wrangler dev+MINIFLARE_WORKERD_PATH=.

I can't observe any difference in behaviour in terms of error handling at the global level, or within a fetch handler, aside from the fact that error throwing/catching is much faster with this change, including during performance profiling.

I say this is good to go.

@mhart mhart force-pushed the mhart/reset-uncaught-flag branch from d079381 to 51b3c61 Compare February 16, 2026 05:57
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.51%. Comparing base (1e9fd8e) to head (51b3c61).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5342      +/-   ##
==========================================
- Coverage   70.52%   70.51%   -0.02%     
==========================================
  Files         408      408              
  Lines      108816   108819       +3     
  Branches    18000    18001       +1     
==========================================
- Hits        76739    76729      -10     
- Misses      21279    21291      +12     
- Partials    10798    10799       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danlapid danlapid merged commit 8d91571 into cloudflare:main Feb 16, 2026
17 of 18 checks passed
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.

Make SetCaptureStackTraceForUncaughtExceptions configurable for a 26% speed boost

5 participants