Skip to content

lib: add Temporal to frozen intrinsics - #63029

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
Renegade334:freeze-temporal-intrinsics
May 1, 2026
Merged

lib: add Temporal to frozen intrinsics#63029
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
Renegade334:freeze-temporal-intrinsics

Conversation

@Renegade334

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
@Renegade334Renegade334 added dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. labels Apr 29, 2026
@nodejs-github-botnodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 29, 2026
@codecov

codecovBot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.64%. Comparing base (8173251) to head (66cce03).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #63029 +/- ##
==========================================
- Coverage 91.49% 89.64% -1.85% 
==========================================
Files 358 708 +350 Lines 151574 220389 +68815 Branches 23921 42263 +18342 ==========================================
+ Hits 138679 197570 +58891 - Misses 12619 14655 +2036 - Partials 276 8164 +7888 
Files with missing linesCoverage Δ
lib/internal/freeze_intrinsics.js96.97% <100.00%> (+0.08%)⬆️

... and 471 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment threadlib/internal/freeze_intrinsics.js
@Renegade334Renegade334 added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 29, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 29, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ljharbljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you may also want to include Temporal.Now

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Renegade334

Copy link
Copy Markdown
MemberAuthor

you may also want to include Temporal.Now

It's recursively covered by deepFreeze().

@ljharb

Copy link
Copy Markdown
Member

Right, but i meant, you'd want to extract all the static methods inside Temporal.Now to be available as primordials.

@aduh95

Copy link
Copy Markdown
Contributor

Right, but i meant, you'd want to extract all the static methods inside Temporal.Now

Those are recursively covered by deepFreeze:

ArrayPrototypeForEach(intrinsics,deepFreeze);

functiondeepFreeze(root){
/**
* "innerDeepFreeze()" acts like "Object.freeze()", except that:
*
* To deepFreeze an object is to freeze it and all objects transitively
* reachable from it via transitive reflective property and prototype
* traversal.
*/
functioninnerDeepFreeze(node){
// Objects that we have frozen in this round.
constfreezingSet=newSafeSet();
// If val is something we should be freezing but aren't yet,
// add it to freezingSet.
functionenqueue(val){
if(Object(val)!==val){
// ignore primitives
return;
}
consttype=typeofval;
if(type!=='object'&&type!=='function'){
// NB: handle for any new cases in future
}
if(frozenSet.has(val)||freezingSet.has(val)){
// TODO: Use uncurried form
// Ignore if already frozen or freezing
return;
}
freezingSet.add(val);// TODO: Use uncurried form
}
functiondoFreeze(obj){
// Immediately freeze the object to ensure reactive
// objects such as proxies won't add properties
// during traversal, before they get frozen.
// Object are verified before being enqueued,
// therefore this is a valid candidate.
// Throws if this fails (strict mode).
ObjectFreeze(obj);
// We rely upon certain commitments of Object.freeze and proxies here
// Get stable/immutable outbound links before a Proxy has a chance to do
// something sneaky.
constproto=ObjectGetPrototypeOf(obj);
constdescs=ObjectGetOwnPropertyDescriptors(obj);
enqueue(proto);
ArrayPrototypeForEach(ReflectOwnKeys(descs),(name)=>{
constdesc=descs[name];
if(ObjectPrototypeHasOwnProperty(desc,'value')){
// todo uncurried form
enqueue(desc.value);
}else{
enqueue(desc.get);
enqueue(desc.set);
}
});
}
functiondequeue(){
// New values added before forEach() has finished will be visited.
freezingSet.forEach(doFreeze);// TODO: Curried forEach
}
functioncommit(){
// TODO: Curried forEach
// We capture the real WeakSet.prototype.add above, in case someone
// changes it. The two-argument form of forEach passes the second
// argument as the 'this' binding, so we add to the correct set.
freezingSet.forEach(frozenSet.add,frozenSet);
}
enqueue(node);
dequeue();
commit();
}
innerDeepFreeze(root);
returnroot;
}

to be available as primordials.

This has nothing to do with primordials though, it's about forbidding any mutation of intrinsics when node is run with --frozen-intrinsics.

@ljharb

Copy link
Copy Markdown
Member

ah, sorry for my confusion.

@Renegade334Renegade334 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Apr 30, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 1, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 637a98a into nodejs:mainMay 1, 2026
90 of 93 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 637a98a

@Renegade334
Renegade334 deleted the freeze-temporal-intrinsics branch May 1, 2026 09:26
aduh95 pushed a commit that referenced this pull request May 5, 2026
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
PR-URL: #63029
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
@aduh95aduh95 mentioned this pull request May 5, 2026
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.dont-land-on-v22.xPRs that should not land on the v22.x-staging branch and should not be released in v22.x.dont-land-on-v24.xPRs that should not land on the v24.x-staging branch and should not be released in v24.x.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@Renegade334@nodejs-github-bot@ljharb@aduh95@anonrig@legendecas