Skip to content

fix: skip the readiness check when sqlcmd can't run - #350

Merged
dhensby merged 3 commits into
tediousjs:masterfrom
dhensby:fix/readiness-check
Nov 21, 2026
Merged

dhensby merged 3 commits into
tediousjs:masterfrom
dhensby:fix/readiness-check

Conversation

@dhensby

@dhensby dhensby commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

With wait-for-ready: true (the default), the action runs sqlcmd after setup to check that the instance accepts logins. @actions/exec rejects when it can't find sqlcmd on the PATH, and the action didn't catch this. A successful install then failed, the Waiting for database log group stayed open, and the action printed Detail.txt and the error logs as if setup had failed. The GitHub-hosted images include sqlcmd, so this mainly affects self-hosted runners and custom images. The input description and the log messages also gave the wrong number of attempts.

  • Refactor. The readiness loop moves from install() into waitForDatabase() in src/utils.ts, with no change in behaviour. It waits with the setTimeout from node:timers/promises, so the backoff tests use the existing mock and no longer replace the global setTimeout.
  • Attempt count. The check tries to log in 6 times: once, then again after waits of 1, 2, 4, 8 and 16 seconds. action.yml said "A maximum of 10 attempts", and the log messages counted the retries, so the action printed "Database not ready after 5 attempts" after 6 attempts. The messages now count attempts, and the debug log numbers each one ("attempt 2 of 6"). The input description gives the real attempts and waits, and a test checks it against the code.
  • sqlcmd can't run. waitForDatabase() now returns unavailable with the reason when sqlcmd can't run, on the first or a later attempt. The action then skips the check with a warning, and the install succeeds. If setup asked for a reboot (exit code 3010), the action fails with a clear error instead, because it can't tell whether the instance works without that reboot. This matches how a failed readiness check is already fatal after a 3010. The check runs in core.group(), which closes the log group in all cases.
  • Docs. The wait-for-ready description says that the action warns and continues when the database isn't ready or sqlcmd can't run, and fails instead after a 3010. The README "Reboot requests" section and step 7 of the architecture in .github/copilot-instructions.md say the same.
  • Tests. New tests cover a sqlcmd that can't run on the first or a later attempt, a non-Error rejection, a database that becomes ready on the last attempt, each outcome with and without a 3010, wait-for-ready: false, and a check that runs inside its log group.

sqlcmd can't run in one more case that this PR doesn't handle. If sqlcmd.exe exists but Node can't start it (for example because the file is damaged), Node throws while @actions/exec starts the process. The promise that exec returns then never settles, and the action stops with an unhandled rejection. This was already the case before this change, and the fix belongs in @actions/exec.

Closes #325

🤖 Generated with Claude Code

dhensby and others added 3 commits November 21, 2026 14:09
install() retried the sqlcmd login with an exponential backoff, and
its tests had to replace the global setTimeout to run the loop. Move
the loop into waitForDatabase(), which now returns whether the
database became ready and how many retries it made. It waits with the
setTimeout from node:timers/promises, which the utils tests already
mock. The single sqlcmd login moves into queryDatabase().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The readiness check tries to log in up to 6 times: once, then again
after waits of 1, 2, 4, 8 and 16 seconds. The wait-for-ready description
said that it made up to 10 attempts, and the log messages counted the
retries, so the action reported "Database not ready after 5 attempts"
after 6 attempts. Count the attempts, number them in the debug log,
and describe the real attempts and waits in action.yml and the README.
A test checks the description against the attempts and waits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@actions/exec rejects when it can't find sqlcmd on the PATH. The
readiness check didn't catch this, so the action failed after a
successful install, left the "Waiting for database" log group open
and printed Detail.txt and the error logs as if setup had failed.

waitForDatabase() now reports that the check is unavailable when
sqlcmd can't run, and the action skips the check with a warning. If
setup asked for a reboot (exit code 3010), the action fails with a
clear error instead, because it can't tell whether the instance works
without that reboot. The check runs in core.group(), which closes the
log group in all cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhensby
dhensby marked this pull request as ready for review November 21, 2026 14:13
@dhensby
dhensby merged commit e9a4d1c into tediousjs:master Nov 21, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.1.4 🎉

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The readiness check fails a successful install when sqlcmd is not on PATH

1 participant