Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catching exceptions from __initializeService #74

Open
mstephen19 opened this issue May 19, 2023 · 0 comments
Open

Catching exceptions from __initializeService #74

mstephen19 opened this issue May 19, 2023 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@mstephen19
Copy link
Owner

Currently, the following code is in the runner for services:

            // ! temp - enable catching errors in the __initializeService
            // ! hook. This is only temporary because the "terminate()" function
            // ! doesn't actually do anything. Eventually, closing a service should
            // ! be done with message passing for more flexibility.
            const initErrHandler = async (body: WorkerBaseMessageBody) => {
                if (body.type !== WorkerMessageType.WorkerException) return;
                await exceptionHandler?.({
                    error: (body as WorkerExceptionMessageBody).data,
                    terminate: () => {
                        //
                    },
                });
            };

The terminate() functionality is completely empty, but when this function is called, the worker should be terminated. The Service instance isn't created yet though, so service.close() cannot be called (Service is only initialized one the worker has notified that it is ready). The solution is to use message-passing in order to command the worker at a lower level (lower than Service level).

@mstephen19 mstephen19 self-assigned this May 19, 2023
@mstephen19 mstephen19 added the feature New feature or request label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant