这是indexloc提供的服务,不要输入任何密码
Skip to content

Unexpected behaviour when subsequent <await> throws before first one #2748

@vwong

Description

@vwong

Marko Version: 6.0.37

Details

The following code produces the expected result:

static const resolveAfter = (duration) =>
  new Promise((resolve) => setTimeout(resolve, duration));

static const rejectAfter = (duration) =>
  new Promise((_, reject) => setTimeout(reject, duration));

<try>
  <@placeholder>
    <div>wait a</div>
  </@placeholder>
  <@catch>
    <div>error a</div>
  </@catch>
  <await|_|=resolveAfter(500)>
    <div>result a</div>
  </await>
</try>

<try>
  <@placeholder>
    <div>wait b</div>
  </@placeholder>
  <@catch>
    <div>error b</div>
  </@catch>
  <await|_|=rejectAfter(300)>
    <div>result b</div>
  </await>
</try>

Ie, I see the following output:

  • wait a + wait b
  • wait a + error b
  • result a + error b

But if I removed the placeholders in both of them, I only see "result a", with nothing from the second try block.

If I additionally swapped the order of the of the blocks, I get the expected result, which is "error b + result a".

It looks like it doesn't like it when later promises reject before earlier promise resolve (or reject for that matter). This reminds me of this blog post: https://jakearchibald.com/2023/unhandled-rejections/, so maybe it's the same root cause?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:unverified bugA bug report that has not been verified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions