Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: implement interface converter and use it for AbortSignal validation #54965

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jazelly
Copy link
Contributor

@jazelly jazelly commented Sep 16, 2024

This PR contains 2 commits.

The first one implements interface converter as per the spec.
The one after uses the implemented interface converter to properly validate AbortSiganls in AbortSignal.any

Fixes: #54962

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Sep 16, 2024
@jazelly jazelly marked this pull request as ready for review September 16, 2024 11:56
createSequenceConverter,
} = require('internal/webidl');

const {
validateAbortSignal,
Copy link
Contributor

@aduh95 aduh95 Sep 16, 2024

Choose a reason for hiding this comment

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

Shouldn't we update validateAbortSignal – or remove it if we no longer need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried updating it, but it breaks some tests, as it is used variously in other modules. Some modules treat EventTarget with { aborted: boolean; } as a valid AbortSignal, and its test is written in that way.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.03%. Comparing base (53ede87) to head (82da5e9).
Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/webidl.js 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54965      +/-   ##
==========================================
- Coverage   88.07%   88.03%   -0.05%     
==========================================
  Files         652      652              
  Lines      183542   183778     +236     
  Branches    35862    35855       -7     
==========================================
+ Hits       161653   161783     +130     
- Misses      15144    15249     +105     
- Partials     6745     6746       +1     
Files with missing lines Coverage Δ
lib/internal/abort_controller.js 97.90% <100.00%> (-0.01%) ⬇️
lib/internal/webidl.js 93.89% <94.11%> (-0.69%) ⬇️

... and 46 files with indirect coverage changes

@RedYetiDev RedYetiDev added abortcontroller Issues and PRs related to the AbortController API web-standards Issues and PRs related to Web APIs labels Sep 16, 2024
@@ -275,20 +277,34 @@ function createSequenceConverter(converter) {
const val = converter(res.value, {
__proto__: null,
...opts,
context: `${opts.context}, index ${array.length}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This error message change is not semver-major nor minor, as there is only one place using this converter and it's not using the context, i.e. the error message is not even displayable in the userland.

@atlowChemi atlowChemi added the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 18, 2024
@atlowChemi
Copy link
Member

I am marking this as semver-major PRs that contain breaking changes and should be released in the next major version. since as far as I understand, this would break for any user-land implementation of AbortSignal (https://www.npmjs.com/package/abort-controller etc)

@jazelly
Copy link
Contributor Author

jazelly commented Sep 18, 2024

I am marking this as semver-major

I agree this would be a semver-major. Does it mean a CITGM is required?

this would break for any user-land implementation of AbortSignal

Would it be better to remove this change? This is unrelated to the issue that the PR is fixing and it can be avoided.

@KhafraDev
Copy link
Member

Is there any documentation for supporting third party abortcontrollers? If not I could see this landing as a bug fix.

@anonrig anonrig added the needs-benchmark-ci PR that need a benchmark CI run. label Sep 18, 2024
@jazelly
Copy link
Contributor Author

jazelly commented Sep 19, 2024

There is only one benchmark test coverring abort_controller and it's only covering the AbortController.abort, which is, IMO, not affected by this PR.

@anonrig In that case, would it be better if I raise another PR to add benchmark tests to cover AbortSignal.any and aborted, which are the ones affected by this PR, before proceeding this?

@jakecastelli jakecastelli added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 19, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 19, 2024
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Sep 19, 2024

@jakecastelli jakecastelli added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 19, 2024
@RedYetiDev
Copy link
Member

@nodejs/tsc per nodejs/Release#1034

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

Not brand checking AbortSignal was an intentional design choice in order to enable userland to migrate to using Node's AbortSignal.

We can choose to break that compatibility but it would have to be semver-major and require @nodejs/tsc's opinion since it's an ecosystem concern (this is likely to break userland code)

@benjamingr
Copy link
Member

To be clear - since this breaks userland I want to see how the TSC and namely people who were involved in the original discussion ( @jasnell @mcollina @ronag ) feel about this change.

I'm personally +0 (I'd like it but not at the cost of extensive breakage)

@KhafraDev
Copy link
Member

We made the same decision in undici to drop third party AbortController/AbortSignal support.

@benjamingr
Copy link
Member

Thinking about this more userland AbortController libraries have tens of millions of weekly downloads so I'm -0.5 (not for this change but still not blocking)

We made the same decision in undici to drop third party AbortController/AbortSignal support.

When did it happen (assuming it affects Node's fetch)? Was there any breakage?

@atlowChemi
Copy link
Member

I am -1 for this change.
The top 4 user-land implementations on npm have almost 60 million weekly downloads

@KhafraDev
Copy link
Member

When did it happen (assuming it affects Node's fetch)? Was there any breakage?

v7, which is releasing soon-ish. Breakage is unimportant here - it was undocumented behavior that broke compatibility with other implementations and the spec. If we implement a spec, we need to accept its burden too. If there are/were performance concerns, those need to be fixed in node core, not handed off to user land to create crappy (not to be offensive) abortcontroller implementations to be used instead.

@RedYetiDev RedYetiDev removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abortcontroller Issues and PRs related to the AbortController API needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version. web-standards Issues and PRs related to Web APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{aborted: false} is treated as valid AbortSignal but not in other runtimes
9 participants