Skip to content

Conversation

@chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Apr 24, 2025

In WICG/observable#208 it was discovered that
the Chromium Observable implementation has a bug where when you
unsubscribe from a sync iterator and ScriptIterator::CloseSync() tries
to find the iterator's return() method, if the method doesn't exist,
an error is thrown.

This deviates from the spec, where TC39 (delegated to by the Observable
specification) permits a null or undefined return() method without
throwing.

This CL fixes that bug in ScriptIterator::CloseSync() and adds a test.

From reading the code, the same issue should happen for async iterators
too, but I cannot reproduce it with the following code:

window.onunhandledrejection = e => console.log('UNHANDLED!!!');
window.onerror = e => console.log('My stuff');

const asyncIterator = {
  [Symbol.asyncIterator]() {
    return {
      i: 10,
      next () {
        return {value: this.i, done: this.i === 2 ? true : false};
      },
      return: 12,
    }
  }
};

const source = Observable.from(asyncIterator);
const value = await source.first();
console.log(value);

...so I will consider investigating in a follow-up.

Bug: 40282760
Change-Id: Ie5f98c97a0602bf702eb7d2bfb082014381e50cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6480575
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1451144}

In WICG/observable#208 it was discovered that
the Chromium Observable implementation has a bug where when you
unsubscribe from a sync iterator and `ScriptIterator::CloseSync()` tries
to find the iterator's `return()` method, if the method doesn't exist,
an error is thrown.

This deviates from the spec, where TC39 (delegated to by the Observable
specification) permits a null or undefined `return()` method without
throwing.

This CL fixes that bug in `ScriptIterator::CloseSync()` and adds a test.

From reading the code, the same issue should happen for async iterators
too, but I cannot reproduce it with the following code:

```js
window.onunhandledrejection = e => console.log('UNHANDLED!!!');
window.onerror = e => console.log('My stuff');

const asyncIterator = {
  [Symbol.asyncIterator]() {
    return {
      i: 10,
      next () {
        return {value: this.i, done: this.i === 2 ? true : false};
      },
      return: 12,
    }
  }
};

const source = Observable.from(asyncIterator);
const value = await source.first();
console.log(value);
```

...so I will consider investigating in a follow-up.

Bug: 40282760
Change-Id: Ie5f98c97a0602bf702eb7d2bfb082014381e50cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6480575
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1451144}
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit 32fccd0 into master Apr 24, 2025
19 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-6480575 branch April 24, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants