Skip to content

Conversation

@Slamdunk
Copy link
Contributor

Fix #1420

@alexandre-daubois
Copy link
Member

I wonder if this should be in the minimal example as you did or as a note after the snippet. It definitely makes sense to mention it somewhere, just wondering if it's the right place as this snippet is about the minimal worker code to make it work.

@Slamdunk
Copy link
Contributor Author

My thought process is the chances of a project to be so advanced to leverage worker mode and still not ever set once a custom exception handler by set_exception_handler is... zero.

I got bitten very hard in production by this, and I would have loved it to be documented as a baseline

Copy link
Member

@alexandre-daubois alexandre-daubois left a comment

Choose a reason for hiding this comment

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

Alright, works for me

@dunglas
Copy link
Member

dunglas commented Sep 27, 2025

I suggest to reword the comment. set_exception_handler does work as expected in a worker script.

Maybe something like:

// Catch and handle the exception and handle it

I would add a note later about exception handlers, like:

> ![NOTE]
>
> Exception handlers are called only when the worker script ends, which may not be what you expect (use `try`/`catch` in this case).

WDYT?

@Slamdunk
Copy link
Contributor Author

I'm not a native english speaker, so I'm fine with any change request you are asking me, as long as the set_exception_handler word is mentioned somewhere

@Slamdunk
Copy link
Contributor Author

I have rephrased the comment so there's no wrong or bad concepts anymore, as you suggested

@alexandre-daubois alexandre-daubois merged commit ab1ec71 into php:main Oct 6, 2025
1 check passed
@alexandre-daubois
Copy link
Member

Thank you @Slamdunk! 🙂

@Slamdunk Slamdunk deleted the worker_mode_set_exception_handler branch October 6, 2025 07:02
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.

Are set_error_handler and set_exception_handler working?

3 participants