Skip to content

In async function, returns a value in try block will before await statement in finally block #11960

Description

@zbinlin
  • Version: 7.7.3
  • Platform: Arch Linux

Testcase:

async function test() {
    try {
        console.log("1");
        return await Promise.resolve();
    } finally {
        console.log("2");
        await Promise.resolve();
        console.log("3");
    }
}

test().then(() => {
    console.log("4");
});

Expected:

1
2
3
4

Actual:

1
2
4
3

Activity

  1. added
    v8 engineIssues and PRs related to the V8 dependency.
    on Mar 21, 2017
  2. targos commented on Mar 21, 2017

    @targos
    Member

    Thanks for the report.
    This looks like a V8 bug and it is fixed in Canary. I'll try to bisect.

  3. targos commented on Mar 21, 2017

    @targos
    Member

    This was fixed in v8/v8@39642fa

    /cc @nodejs/v8 can we safely backport this commit to Node 7 (V8 5.5) and/or V8 5.7 ?

  4. bnoordhuis commented on Mar 21, 2017

    @bnoordhuis
    Member

    I don't know, you'd have to try. 5.7 should be an easier target than 5.5. If a full back-port is too onerous, you might be able to get away with dropping the ignition (interpreter) changes.

  5. targos commented on Mar 21, 2017

    @targos
    Member

    It seems to work fine on 5.7. I added the backport to #11752

  6. targos commented on Mar 21, 2017

    @targos
    Member

    I attempted a backport (without looking in depth at the changes; just applied the patch and fixed conflicts) to v7.x-staging in targos@46b0159. It compiles and the Node.js test suite passes but the OP's testcase only prints

    1
    2
    3
    
  7. gsathya commented on Mar 22, 2017

    @gsathya
    Member

    You need the ignition changes for this to work. Can you try merging https://codereview.chromium.org/2672313003/ to 5.5? This is a fix in the parser, instead of ignition. This might be easier to merge.

  8. targos commented on Mar 22, 2017

    @targos
    Member

    Thank you @gsathya. It's indeed easier to merge. I backported https://codereview.chromium.org/2633353002 with it.
    I will do some testing and open a PR tomorrow.

  9. targos commented on Mar 23, 2017

    @targos
    Member
  10. added a commit that references this issue on Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions