Skip to content

Deploy is marked as successful if thrown error message is empty #47

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

Open
birtles opened this issue Mar 31, 2025 · 1 comment
Open

Deploy is marked as successful if thrown error message is empty #47

birtles opened this issue Mar 31, 2025 · 1 comment
Assignees

Comments

@birtles
Copy link

birtles commented Mar 31, 2025

If you do the following in your workflow:

throw new Error('');

The deploy is treated as successful.

Image

Image

Why does this matter? A lot of tasks fail without writing anything to stderr, e.g. sst deploy itself.

As a result, if you do await $`pnpm sst deploy` we write an empty string to WORKFLOW_RESULT file:

` const result = e.name === "ShellError"`,
` ? { error: e.stderr.toString().trim() }`,
` : { error: e.message };`,
` fs.writeFileSync("${WORKFLOW_RESULT}", JSON.stringify(result));`,

That gets transformed into an Error with an empty message here:

try {
shellError = new Error(
JSON.parse(fs.readFileSync(WORKFLOW_RESULT, "utf8")).error,
);
} catch (_) {}
throw shellError;

As a result, even if sst deploy fails (or astro check or tsc --noEmit etc.) the deploy is treated as successful. Furthermore, steps following the error don't run.

@birtles
Copy link
Author

birtles commented Mar 31, 2025

For what it's worth, I'm currently working around this by wrapping every command up in an explicit exit code check and re-throwing as regular Error (not a ShellError):

{
  const { exitCode } = await $`pnpm astro check`.nothrow();
  if (exitCode !== 0) {
    throw new Error('`astro check` failed');
  }
}

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

No branches or pull requests

2 participants