Skip to content

[Bug]: async function with catch return makes babel a wrong output #17425

@ch1ny

Description

@ch1ny

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

const replay = async () => {
  try {
  } catch (error) {
    console.log('@kira', 'error', error);
    return false;
  }

  throw new Error('@kira throw');
};

Configuration file name

No response

Configuration

No response

Current and expected behavior

You can see a minimal reproduction at here

This function should throw error directly, but the error would actually be caught.

Image

Environment

System:
OS: macOS 14.6.1
Binaries:
Node: 18.20.8 - ~/Desktop/projects/test/node_modules/.bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v18.20.5/bin/npm
pnpm: 8.9.2 - /usr/local/bin/pnpm
npmPackages:
@babel/runtime: ^7.21.5 => 7.27.6

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions