Skip to content

Exit rather than return in the release decider - #15

Merged
pathscale merged 1 commit into
masterfrom
fix/release-js-top-level-return
Sep 1, 2026
Merged

Exit rather than return in the release decider#15
pathscale merged 1 commit into
masterfrom
fix/release-js-top-level-return

Conversation

@pathscale

Copy link
Copy Markdown
Owner

The first push to master under the new release workflow failed. decide in
release-js.yml died with:

SyntaxError: Illegal return statement

node -e evaluates a script without the CommonJS module wrapper, so the
top-level return that ends the tag branch and the dispatch branch is not
legal there. The job never got as far as choosing a package.

The oxc workflow was unaffected, has no such script, and published
solid-layouts-oxc@0.2.3 from the same push as intended.

The fix

Both branches now end in process.exit(0), which is the idiom the error
paths in the same script already use, and which is safe because emit
appends to GITHUB_OUTPUT synchronously.

How this got through

It was checked by extracting the script to a .cjs file and running it.
CommonJS wraps a module in a function, so a top-level return is legal in
that setting and every path passed. The extraction is what made the test
pass.

Checking it now means running the step's run: block as bash, the way the
runner does. All five paths, against the live registry:

path outcome
push to master packages=[] publish=false any=false, both packages reported already on npm
tag, version matches selects the package, publish=true
workflow_dispatch selects the package, publish=false
tag, version mismatch exit 1, expected tag solid-layouts-v0.2.1
dispatch, unknown package exit 1

The push path emitting nothing is the intended result: both JavaScript
packages are at 0.2.1 and 0.2.1 is published, so a merge that touches no
version releases nothing.

No version bump: this changes CI only, and no published package contents.

`node -e` has no CommonJS module wrapper, so a top-level `return` is a
SyntaxError and the decide job died before it chose anything. The tag and
dispatch branches both ended in one, which is why the first push to master
under the new workflow failed instead of publishing nothing.

`process.exit(0)` is what the surrounding code already reaches for on the
error paths, and `emit` writes synchronously, so the outputs are on disk
before the exit.

The mistake was in how this was checked, not only in the code: the script
was extracted to a .cjs file and run, and CommonJS wraps a module in a
function, which makes a top-level return legal. Verifying it now means
running the `run:` block as bash, the way the runner does.
@pathscale
pathscale merged commit 3e1dcc2 into master Sep 1, 2026
5 checks passed
@pathscale
pathscale deleted the fix/release-js-top-level-return branch September 1, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant