-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: attach a catch handler to the handleContentP promise #250
Conversation
There is an error handler set up on the promise at Line 92 in 2e1383d
But it only happens during flush, way too late. |
lib/content/write.js
Outdated
@@ -67,6 +67,7 @@ class CacacheWriteStream extends Flush { | |||
this.cache, | |||
this.opts | |||
) | |||
this.handleContentP.catch(error => this.destroy(error)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.destroy
seems to be overreaching in scope. I think we want cb(error)
We can also attach it directly to the function call handleContent().catch()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this does not help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.destroy seems to be overreaching in scope
Yes, I changed it to emit the error instead. Seems to work and does not break the test coverage.
Why? It will still be a rejected promise. It is currently a try...finally block. If it is changed to try...catch, the error should still go somewhere. And it could be also error coming from |
Looks good w/ just the simple .catch added. Were you able to test this against your example in #249? |
Yes, I tested it and it works fine. |
This attaches a catch handler to the handleContentP promise, as in some cases the flush is not called before node decides that this is an unhandled promise rejection.
Fixes #249