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
And, sendRequest uses axios to send requests, it seems all 2xx status code will be treated as a success, while others will throw a exception which crashes the entire server. The line 109 shows
if (response.status !== 200 || !response.data)
return;
Maybe, don't hard code response.status !== 200 will be nice, because POST responses of nestjs will contain a 201 status code by default and axios considers it as a success.
Summary
add catch to axios.post
remove response.status !== 200
That's my own adverise, welcome to discuss.
Environment?
Hocuspocus version: v2.11.2
The text was updated successfully, but these errors were encountered:
@wxfred I've just quickly checked but as far as I could see, all sendRequest calls are wrapped in try/catch with console.error as the error handler. Can you share the stack trace of the crash?
@janthurau Thanks for your prompt, I located the error, the original code didn't add async/await to axios, sendRequest returns a promise, and here are my changes
Description
If my nestjs server returns a 400 status code response to the onChange webhook, the hocuspocus will crash.
I see there is no catch clause in hocuspocus-webhook.esm.js
Is it suitable to add a catch like below?
And, sendRequest uses axios to send requests, it seems all 2xx status code will be treated as a success, while others will throw a exception which crashes the entire server. The line 109 shows
Maybe, don't hard code response.status !== 200 will be nice, because POST responses of nestjs will contain a 201 status code by default and axios considers it as a success.
Summary
That's my own adverise, welcome to discuss.
Environment?
The text was updated successfully, but these errors were encountered: