Skip to content

[Bug?]: yarn rw exec always exits with code 0, even if the script throws an error #7647

@rcrogers

Description

@rcrogers

What's not working?

Exceptions in exec scripts do not alter the exit status.

Probably need to rethrow in this catch:
https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/commands/execHandler.js#L118

        try {
          await runScriptFunction({
            path: scriptPath,
            functionName: 'default',
            args: { args: scriptArgs },
          })
        } catch (e) {
          console.error(c.error(`Error in script: ${e.message}`))
        }

How do we reproduce the bug?

% echo "export default () => { throw Error('bye') }" > scripts/hello.ts
% yarn rw exec hello && echo "shouldn't be here"                       
[STARTED] Generating Prisma client
[SUCCESS] Generating Prisma client
[STARTED] Running script
Error in script: bye
[SUCCESS] Running script
shouldn't be here
% echo $!                                                              
0

What's your environment? (If it applies)

System:
    OS: macOS 13.0
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.0.0 - /private/var/folders/rv/vqq6nq755l5d_z2v4mzpf4qr0000gn/T/xfs-c9525f18/node
    Yarn: 3.2.3 - /private/var/folders/rv/vqq6nq755l5d_z2v4mzpf4qr0000gn/T/xfs-c9525f18/yarn
  Databases:
    SQLite: 3.39.4 - /usr/bin/sqlite3
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 16.1
  npmPackages:
    @redwoodjs/core: ^3.8.0 => 3.8.0

Are you interested in working on this?

  • I'm interested in working on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/confirmedWe have confirmed this is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions