Repository navigation
Conversation
|
No actionable comments were generated in the recent review. WalkthroughThe ChangesFileHandle close binding
mkdtempSync test prefix
Possibly related PRs
Suggested reviewers: Merge Risk:
|
|
A note on one effect of this change that its title does not name. Two things follow from it:
class Holder {
constructor(fh) {
this.fh = fh;
}
}
const fh = await fsp.open(file, "r");
new Worker(workerFile, { workerData: { fh, holder: new Holder(fh) }, transferList: [fh] });
// main: the worker gets the FileHandle (holder.fh arrives as a plain object)
// with this change: DataCloneError: The object can not be cloned.
// node v26.3.0: the worker gets the FileHandle in both places |
|
Confirmed on the current Linux build: the close-binding change makes the class-instance transfer case throw |
Preserve existing clone and transfer behavior while keeping close bound to its owning handle. Cover worker transfer when a class instance also references the transferred handle.
|
Fixed the transfer regression in 2c12f2738d: |
Calling
close()through a forwarding Proxy around aFileHandle, or after detaching the method, uses the receiver instead of the owning handle. Node bindsFileHandle.closeto the handle.Bind the existing asynchronous method in the constructor as a non-enumerable, writable, configurable own property. The close and finalizer logic stays unchanged. Keeping the function non-enumerable fixes the regression where a worker transfer threw
DataCloneErrorif the message also reached the transferred handle through a class instance. Tests cover direct and nested proxies, get traps, detached calls, foreign receivers, repeated close calls, descriptor recycling, and that class-instance transfer case, with Node controls.This preserves main's clone behavior, including its existing differences from Node. Bun's
Object.keys(fh)excludesclose, while Node's includes it. Bun still clones open and closed handles throughstructuredClone,v8.serialize, andpostMessagewithout a transfer list; Node refuses those clones. In the class-instance transfer case, Bun still produces a plain object for the nested reference, while Node preserves the same FileHandle in both positions. The transfer-graph gap is pre-existing and unchanged. The FileHandle test proposed by #35841 therefore remains an expected failure; itsexpectFailureoption needs no change.Validation on Linux release builds: the new transfer regression fails with
DataCloneErroron the original PR head630023eefand passes on2c12f2738. The completetest/js/node/fs/fs.test.tsfile has 637 passes, 8 skips, and the five expected forwarding/detached-close failures on main canary1.4.4-canary.1+b1007f117; the candidate has 642 passes, 8 skips, and no failures. This includes all forwarding/finalizer cases and Node 26.12.1 controls. All six open/closed structuredClone, v8.serialize, and MessagePort.postMessage results match main, as do both direct Worker.postMessage checks. Prettier, diff checks, and independent P0–P2 review pass.Ported from openclaw#183.