JS-DevTools / npm-publish

GitHub Action to publish to NPM
https://jstools.dev/npm-publish
MIT License
620 stars 74 forks source link

Publish failure message is masked by `TypeError: _b.toUpperCase is not a function` #119

Closed andybalaam closed 1 year ago

andybalaam commented 1 year ago

Hi, our NPM publish failed after your (much-appreciated) change to upgrade us to npm-publish@v2:

https://github.com/matrix-org/matrix-react-sdk/actions/runs/5520127165/jobs/10066320474

but the error message is masked by this error:

Run JS-DevTools/npm-publish@a25b4180b728b0279fca97d4e5bccf391685aead
Error: TypeError: _b.toUpperCase is not a function

This seems to be caused by this line:

errorCode = errorPayload?.error?.code?.toUpperCase();

from https://github.com/JS-DevTools/npm-publish/blob/main/src/npm/call-npm-cli.ts#L79

It looks like the code is not a string?

mcous commented 1 year ago

How embarrassing! Thanks for the report and the helpful lesson in making assumptions when consuming JSON from third parties.

I've just released 2.2.1 which will resolve the TypeError and let us see what's actually going on. I also added some extra debug logging around the call to the npm CLI which could help in the future.

I'll keep an eye out in case whatever issue this was hiding is also related to a bug here

- uses: JS-DevTools/npm-publish@5a85faf05d2ade2d5b6682bfe5359915d5159c6c # v2.2.1
andybalaam commented 1 year ago

Don't be embarrassed :-) We've upgraded to 2.2.1 and we'll find out on Tuesday whether it improves matters.

Thanks for the fix!

andybalaam commented 1 year ago

Hi, we still got a failure (for still-mysterious reasons, since it works for me on my dev machine...) and the error, while different, is no more enlightening:

https://github.com/matrix-org/matrix-react-sdk/actions/runs/5555607767/jobs/10146998436

Error: NpmCallError: Call to "npm publish" exited with non-zero exit code 1
error Command failed with exit code 1.
error Command failed with exit code 1.

Do you have any ideas how we can find out what is going on?

Thanks for your help!

mcous commented 1 year ago

Hi @andybalaam, if you haven't already, you could try re-running the job with debug enabled from the GitHub UI. This will print the exact npm call used and any stdout or stderr from the CLI, which could give us more insight.

I'm on vacation with my family until Friday, but I can take a closer look on Saturday!

mcous commented 1 year ago

A random thought: I know y'all run a pre-publish script which runs a build step. Perhaps it is that build script that is failing? Might explain the lack of info from npm, because expected stuff like auth failures have well defined codes that you would be seeing if that was the cause

andybalaam commented 1 year ago

Hi @andybalaam, if you haven't already, you could try re-running the job with debug enabled from the GitHub UI. This will print the exact npm call used and any stdout or stderr from the CLI, which could give us more insight.

Thank you for the tip - I have done that here: https://github.com/matrix-org/matrix-react-sdk/actions/runs/5587454119/jobs/10212963945 and I can see there are errors from our TypeScript process.

I'm on vacation with my family until Friday, but I can take a closer look on Saturday!

Enjoy your holiday and don't give this another thought! You have already helped a bunch.

A random thought: I know y'all run a pre-publish script which runs a build step. Perhaps it is that build script that is failing? Might explain the lack of info from npm, because expected stuff like auth failures have well defined codes that you would be seeing if that was the cause

Yes, you were right. Now I will attempt to figure out why ... :-)