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

Handle response data #21

Merged
merged 5 commits into from
Feb 18, 2024
Merged

Handle response data #21

merged 5 commits into from
Feb 18, 2024

Conversation

magnetikonline
Copy link
Member

@magnetikonline magnetikonline commented Feb 16, 2024

After the bump to Node.js v20 with #20 - it's become clear that a https.request() must have data events handled within the response - otherwise Node.js will hang/wait and will not exit.

This resulted in a Slack message that would be sent instantly as per before - but then the workflow job would "hang" until tje GitHub Actions runner finally times the process out after three minutes of inactivity. Ouch!

So this change will add a dummy handler of resp.on('data',function() {}); and throw away the response payload (we don't need/want it).

Also:

  • Bumped @actions/core and @actions/github.
  • Bumped esbuild.
  • Qualified all require()s for stdlib modules with node:*.

Comment on lines +192 to +193
// throw away response
resp.on('data',function() {});
Copy link
Member Author

@magnetikonline magnetikonline Feb 16, 2024

Choose a reason for hiding this comment

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

Ensure response data is handled - otherwise Node.js won't end/finish up.

We don't need the response body (HTTP status code is enough) - so simply junk the data received.

I assume the Node.js v20 stream implementation leaves behind a latent Promise/etc. in the case the data returned isn't consumed (maybe?). Couldn't find a concrete change/reason in online docs/etc.

Choose a reason for hiding this comment

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

Is this a known bug? Seems like a pretty basic requirement to fire-and-forget requests!

Copy link
Member Author

@magnetikonline magnetikonline Feb 18, 2024

Choose a reason for hiding this comment

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

I don't believe so @jack-green - as we're a few point releases into v20 now and assume it's "desired". But without any code changes, moving between v18 -> v20 - the HTTPS request is made (and Slack message posted) - but the Node process will then "hang" indefinitely - so I can only assume it's a latent Promise awaiting the resolve?

In GitHub Actions land - the action is forcefully killed after three minutes - due to this inactivity - which is nice - but isn't a solution :)

Found this - but this goes right back to Node.js 0.10 - but seems to hint it's a paused socket that remains - this could make sense too.

Comment on lines +3 to +4
const https = require('node:https'),
url = require('node:url'),
Copy link
Member Author

Choose a reason for hiding this comment

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

Use node:* naming for stdlib requires.

Copy link

@jack-green jack-green left a comment

Choose a reason for hiding this comment

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

You're now the tip of the node spear, we're still stuck on 18.12 in yewie land at the moment!

@magnetikonline magnetikonline merged commit f1aed49 into main Feb 18, 2024
1 check passed
@magnetikonline magnetikonline deleted the handle-response-data branch February 18, 2024 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants