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

failOnError does not abort generation #574

Open
KieranKaelin opened this issue Apr 2, 2024 · 1 comment
Open

failOnError does not abort generation #574

KieranKaelin opened this issue Apr 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@KieranKaelin
Copy link

Describe the bug
@pgtyped/cli does not respect the failOnError flag during generation.

Expected behavior
The workers should stop, and the process should exit with code 1.

Test case

  • In packages/example, add "failOnError": true to config.json
  • In any of the *.sql files, modify a statement to be incorrect.
  • Execute npm run typegen
  • The error will appear in the log, but execution does not stop, and echo $? returns 0

From my novice eye, it seems that this regression stems from e5f920e (as cdfadfb, the previous commit, is working as expected), specifically the changes in packages/cli/src/index.ts#L40.

I made a quick local test, replacing this.pool.run(opts, { name: functionName }); with

const result = await this.pool.run(opts, { name: functionName });
if (result.error) {
  throw result.error;
}
return result;

Rerunning npm run typegen now behaves as expected, immediately stopping all workers as it encounters the erroneous file, and exiting with code 1.

@KieranKaelin KieranKaelin added the bug Something isn't working label Apr 2, 2024
@mrjackdavis
Copy link
Contributor

mrjackdavis commented May 8, 2024

Here's an unfortunate workaround for those who butt up against this

pgtyped -c ./pgtyped.config.cjs 2>&1 | tee  /dev/tty | grep 'Error:' && exit 1 || exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants