If an error is thrown during context creation the requestDidStart hook is not called. As a result, using didEncounterErrors is not possible for those errors.
Note: formatError function is called
Thanks for reporting this issue! It's possible this has been resolved, but I can't be certain because there's no reproduction here to try quickly.
As requested in the issue template when you submitted this issue, GitHub Issues need to include simple, runnable reproductions. This means either a GitHub repository that anyone can clone and run and see the problem or an example built using the Apollo Server CodeSandbox template or by "re-mixing" the Apollo Server Glitch template.
Building reproductions takes a large portion of core contributor's and issue triager's time and without a runnable reproduction, we'll have to close this issue in the next 7 days. Hope you understand!
If you aren't able to supply a runnable reproduction, we're happy to re-open this later on when one can be provided. Regardless, thanks again for filing the issue since, reproduction or not, this information could be useful for a future visitor!
I have the same issue where the requestDidStart hook is not called, here's the reproduction I made. It cause the code you provide here to not work because the plugin is never called. Hope it will help!
+1 I'm having the exact same issue as @cbdt. Please just let us know if we're doing something wrong or if the hook is not working as intended.
I'm having the same issue as well.
Throwing any error during context creation make the request status to be HTTP 400 with correct error in the errors array but skip the requestDidStart hook.
Although I assume this is expected (the 400 status), the hook not being called prevent us to use the workaround for the 401 http status.
any progress on this?
Most helpful comment
I have the same issue where the requestDidStart hook is not called, here's the reproduction I made. It cause the code you provide here to not work because the plugin is never called. Hope it will help!