Closed vripoche closed 5 years ago
Hello @vripoche, what is the exact use-case? You can't do it in the React world?
Hello @neoziro ,
My use case is to log errors to Sentry through the node module (SSR side): https://www.npmjs.com/package/@sentry/node
I tried to do that in _errror.js
or with ErrorBoundaries in _app.js
but the module cannot be loaded in browser, and that files are loaded both in SSR and in browser.
If I read the Express documentation I should add an error middleware, and I should add it in onCreateServer
hook, but it is not working.
@vripoche OK I understand the point. I will merge it as soon as I have time.
Hello @neoziro,
Did you have enough time to review this PR ? ;)
Thanks for your attention.
Hi,
Due to the unability of add error middleware in
onCreateServer
hook because the hook call is before SSR middleware, I propose to add a new node hook to manage SSR errors in project plugins:onServerError
. It is called on each server error, with error (and other hook parameters asconfig
) in first argument. It also takes the plugin config as a second parameter if it needed.