You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation states to reject the promise (or throw null) to stop a hook chain.
If the Promise in a hook is rejected it will not be called for the following extensions or your configuration. It's like a stack of middlewares a request has to go through. Keep that in mind when working with hooks.
However this has some unintended side effects for some chains. For example, rejecting an onLoadDocument hook doesn't just prevent the next hook in the chain from executing, but the error bubbles up to the next catch. In my case it was caught by onAuthenticate logic causing it to look like an unauthorized request.
What I expect it to do is prevent the remaining onLoadDocument hooks from executing but continue normal execution.
How are we supposed to interrupt chains such as onLoadDocument? Perhaps add a catch to all hook calls to ensure the error doesn't bubble up outside the hook chain?
Also, I wonder if rejecting promises is the best way to handle interrupting the hook chain. It means we can't process return values and stop the chain at the same time. It also means unexpected errors might be caught and silenced thinking we're just trying to stop the hook chain. Perhaps a callback funciton could be provided to stop the hook chain instead of relying on rejected promises.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The documentation states to reject the promise (or
throw null
) to stop a hook chain.However this has some unintended side effects for some chains. For example, rejecting an
onLoadDocument
hook doesn't just prevent the next hook in the chain from executing, but the error bubbles up to the nextcatch
. In my case it was caught byonAuthenticate
logic causing it to look like an unauthorized request.What I expect it to do is prevent the remaining
onLoadDocument
hooks from executing but continue normal execution.How are we supposed to interrupt chains such as
onLoadDocument
? Perhaps add acatch
to all hook calls to ensure the error doesn't bubble up outside the hook chain?Also, I wonder if rejecting promises is the best way to handle interrupting the hook chain. It means we can't process return values and stop the chain at the same time. It also means unexpected errors might be caught and silenced thinking we're just trying to stop the hook chain. Perhaps a callback funciton could be provided to stop the hook chain instead of relying on rejected promises.
Beta Was this translation helpful? Give feedback.
All reactions