Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace .abort() with .destroy() #317

Merged
merged 1 commit into from
May 11, 2023
Merged

fix: Replace .abort() with .destroy() #317

merged 1 commit into from
May 11, 2023

Conversation

trygve-lie
Copy link
Contributor

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 the req.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 of req.destroy(). Calling req.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

@trygve-lie trygve-lie requested a review from digitalsadhu May 11, 2023 13:10
Copy link
Member

@digitalsadhu digitalsadhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top sleuthing Mr Lie. 💯

@digitalsadhu digitalsadhu merged commit 1888da6 into master May 11, 2023
@digitalsadhu digitalsadhu deleted the econnreset branch May 11, 2023 19:13
@github-actions
Copy link

🎉 This PR is included in version 4.5.31 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 5.0.0-next.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants