fix: Replace .abort() with .destroy() #317
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an bug where a version change in a podlet causes the client to terminate the request to the podlets content due to detecting a version change, but instead of re-fetching the manifest etc it closes the connection and resolves with the fallback. This causes the client to never re-fetch the manifest and fallback of a podlet.
The roots cause are these changes in node.js 14 (iow; these error started with node 14): nodejs/node#32182 nodejs/node#32225
When requesting a podlet the client needs to listen for errors in case of network issues. In the case of a network error the client will then return the fallback it has. But we also need to detect an update of a podlet (version change) and in the case of a update, the ongoing request to the content needs to be terminated and we need to re-fetch the manifest and fallback etc. We terminate this ongoing request with
req.abort()
.Pre node 14 calling
req.abort()
have NOT emitted an error event but with node 14 calling thereq.abort()
method started to emit an error event. When a error event is emitted the above logic fails and in stead of restarting the dance of updating the manifest etc, the request have returned with a fallback causing the layout to never re-fetch an update of the manifest.From node 14 the
req.abort()
method have been deprecated in favor ofreq.destroy()
. Callingreq.destroy()
without passing on an error object will not cause an error event to be emitted which will ensure the original logic for detecting version changes to function as it should