mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
worker: unify custom error creation
Mostly, this introduces a pattern that makes sure that if a custom error is reported, `stopped_` will be set to `true` correctly in every cast, which was previously missing for the `NewContext().IsEmpty()` case (which led to a hard crash from the `Worker` destructor). This also leaves TODO comments for a few cases in which `ERR_WORKER_OUT_OF_MEMORY` was not used in accordance with the documentation for that error code (or according to its intention). Fixing that is semver-major. PR-URL: https://github.com/nodejs/node/pull/33084 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
2 files changed
+22
-15
No files matched your search
+5
-2
@@ -34,8 +34,11 @@ class Worker : public AsyncWrap {
|
||||
void Run();
|
||||
|
||||
// Forcibly exit the thread with a specified exit code. This may be called
|
||||
// from any thread.
|
||||
void Exit(int code);
|
||||
// from any thread. `error_code` and `error_message` can be used to create
|
||||
// a custom `'error'` event before emitting `'exit'`.
|
||||
void Exit(int code,
|
||||
const char* error_code = nullptr,
|
||||
const char* error_message = nullptr);
|
||||
|
||||
// Wait for the worker thread to stop (in a blocking manner).
|
||||
void JoinThread();
|
||||
|
||||
Reference in new issue
Block a user