Skip to content

util: freeze kEnumerableProperty - #43390

Merged
LiviaMedeiros merged 1 commit into
nodejs:masterfrom
LiviaMedeiros:util-freeze-kenobirable-property
Jun 15, 2022
Merged

util: freeze kEnumerableProperty#43390
LiviaMedeiros merged 1 commit into
nodejs:masterfrom
LiviaMedeiros:util-freeze-kenobirable-property

Conversation

@LiviaMedeiros

Copy link
Copy Markdown
Member

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jun 12, 2022
@LiviaMedeirosLiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2022
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2022
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment on lines 32 to 40

@aduh95aduh95Jun 12, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't really seem like something we need to care in our tests (in no credible scenario will anyone tries to check what's the value of Object.isSealed(kEnumerableProperty) in core, and if there was a way to make sure the object always behaves as we want it to that doesn't involve freezing it, that'd be fine too), the consequences are what's really important to test imo:

Suggested change
assert.strictEqual(
Object.isExtensible(kEnumerableProperty),
false
);
assert.strictEqual(
Object.isSealed(kEnumerableProperty),
true
);
assert.strictEqual(
Object.isFrozen(kEnumerableProperty),
true
);
assert.throws(
()=>{kEnumerableProperty.configurable=false;},
TypeError
);
assert.throws(
()=>Object.assign(kEnumerableProperty,{configurable: false}),
TypeError
);
assert.throws(
()=>Object.assign(kEnumerableProperty,{enumerable: false}),
TypeError
);

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Conceptually agreed. :)
My concern here is that by assuming alternatives to freezing and possibility of something dangerous (e.g. if there will be unavoidable exposing reference to kEnumerableProperty for userland) we must keep in mind every single way to break it.
If that approach will become common in core, we'll have to create an exhaustive isImmutable() helper function instead.

@aduh95aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 12, 2022
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2022
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/44460/

@LiviaMedeirosLiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2022
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2022
@LiviaMedeirosLiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2022
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2022
@LiviaMedeiros

Copy link
Copy Markdown
MemberAuthor

@nodejs-github-bot

nodejs-github-bot commented Jun 13, 2022

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

This comment was marked as duplicate.

@LiviaMedeiros
LiviaMedeirosforce-pushed the util-freeze-kenobirable-property branch from 174856c to 7a84b9bCompareJune 14, 2022 15:07
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

PR-URL: nodejs#43390
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@LiviaMedeiros
LiviaMedeirosforce-pushed the util-freeze-kenobirable-property branch from 7a84b9b to 0f90879CompareJune 15, 2022 08:42
@LiviaMedeiros
LiviaMedeiros merged commit 0f90879 into nodejs:masterJun 15, 2022
@LiviaMedeiros

Copy link
Copy Markdown
MemberAuthor

Landed in 0f90879

danielleadams pushed a commit that referenced this pull request Jun 16, 2022
PR-URL: #43390
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@danielleadamsdanielleadams mentioned this pull request Jun 16, 2022
targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #43390
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #43390
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@targostargos mentioned this pull request Aug 3, 2022
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#43390
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@LiviaMedeiros@nodejs-github-bot@jasnell@benjamingr@lpinca@BethGriggs@aduh95