handle uncaught exceptions in worker (#69335)
Previously any uncaught exception in a build worker would lead to the
worker process being exited. This change adds a custom handler to only
terminate the process if the error is a Next.js specific API that
expects to be called in a context where the framework can observe it.
Other errors that are uncaught are logged but won't terminate the worker
process.