Skip to content

Conversation

@tewaro
Copy link
Contributor

@tewaro tewaro commented Jul 24, 2024

Small bug fix, where prototype for cache was not gated behind the compatibility flag in #2409.

@tewaro tewaro requested review from a team as code owners July 24, 2024 01:38
@tewaro tewaro requested review from a-robinson and hoodmane July 24, 2024 01:38
const req = new Request('https://example.org', { cache: 'no-store' });
assert.strictEqual(req.cache, 'no-store');
} else {
assert.throws(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we also be putting this new behaviour (throwing when cache is present) behind the compatibility flag too?

Copy link
Member

Choose a reason for hiding this comment

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

When the compat flag is off, we need to be using the old jsg::Unimplemented definition, which would make this code irrelevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can't exactly be using that dynamically it's part of the type right? Should we just be throwing the same error?

Copy link
Member

Choose a reason for hiding this comment

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

Sure you can make it dynamic. Rename jsg::Unimplemented getCache(); to jsg::Unimplemented getUnimplementedCache();, then do something like this in the JSG_RESOURCE_TYPE block:

if (flags.getCacheOptionEnabled()) {
  JSG_READONLY_PROTOTYPE_PROPERTY(cache, getCache);
} else {
  JSG_READONLY_PROTOTYPE_PROPERTY(cache, getUnimplementedCache);
}

So the exported cache property in JS hooks up to different implementations depending on the flag.

@tewaro tewaro force-pushed the AdityaAtulTewari/enable-prototype-compatability-for-cache-no-store branch from 6257929 to cc84143 Compare July 24, 2024 14:18
@kentonv
Copy link
Member

kentonv commented Jul 24, 2024

Can we please completely revert the previous change, and then re-land? I want to be able to see a diff from the known-good state to the final state, so I can verify that everything new has been properly gated.

@tewaro tewaro marked this pull request as draft July 24, 2024 15:24
@tewaro tewaro closed this Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants