Skip to content

fix: return numeric blksize and blocks from asar fs.stat#50825

Merged
codebytere merged 1 commit into
mainfrom
clavin/asar-stat-blksize-blocks
Apr 10, 2026
Merged

fix: return numeric blksize and blocks from asar fs.stat#50825
codebytere merged 1 commit into
mainfrom
clavin/asar-stat-blksize-blocks

Conversation

@clavin
Copy link
Copy Markdown
Member

@clavin clavin commented Apr 8, 2026

Description of Change

fs.stat on files inside .asar archives returned undefined for blksize and blocks, breaking the soundness of node:fs types expecting number | bigint.

This change sets blksize: 4096 and computes blocks: Math.ceil(size / 512). This happens to align with the proposed node:vfs module (nodejs/node#61478). Added a test to continue validating the general property typeof asar[key] === typeof real[key].

Fixes #42686

Checklist

Release Notes

Notes: Fixed fs.stat on files inside asar archives returning undefined for blksize and blocks instead of numeric values.

@clavin clavin added bug 🪲 semver/patch backwards-compatible bug fixes target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Apr 8, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Apr 8, 2026
@clavin clavin marked this pull request as ready for review April 8, 2026 22:59
Previously, `fs.stat` on files inside `.asar` archives returned
`undefined` for `blksize` and `blocks`, violating the Node.js API
contract where these fields must be `number | bigint`.

Use `4096` for `blksize` (matching the convention used by `memfs` and
the proposed `node:vfs` module in nodejs/node#61478) and compute
`blocks` as `ceil(size / 512)` (standard 512-byte block units).

Fixes #42686

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clavin clavin force-pushed the clavin/asar-stat-blksize-blocks branch from bdf33ba to 7b653fe Compare April 8, 2026 23:01
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Apr 9, 2026
@codebytere codebytere merged commit 8b7e7de into main Apr 10, 2026
66 checks passed
@codebytere codebytere deleted the clavin/asar-stat-blksize-blocks branch April 10, 2026 08:19
@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Apr 10, 2026

Release Notes Persisted

Fixed fs.stat on files inside asar archives returning undefined for blksize and blocks instead of numeric values.

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Apr 10, 2026

I have automatically backported this PR to "40-x-y", please check out #50875

@trop trop Bot added in-flight/40-x-y and removed target/40-x-y PR should also be added to the "40-x-y" branch. labels Apr 10, 2026
@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Apr 10, 2026

I have automatically backported this PR to "41-x-y", please check out #50876

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Apr 10, 2026

I have automatically backported this PR to "42-x-y", please check out #50877

@trop trop Bot added in-flight/41-x-y in-flight/42-x-y merged/41-x-y PR was merged to the "41-x-y" branch. and removed target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/41-x-y labels Apr 10, 2026
@trop trop Bot added merged/42-x-y PR was merged to the "42-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. and removed in-flight/42-x-y in-flight/40-x-y labels Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: fs.stat blksize/blocks are undefined for .asar files

3 participants