Skip to content

Make async readJson match sync throws: false behavior - #1089

Closed
vhinayindia wants to merge 1 commit into
jprichardson:masterfrom
vhinayindia:fix/readjson-throws-consistency
Closed

vhinayindia wants to merge 1 commit into
jprichardson:masterfrom
vhinayindia:fix/readjson-throws-consistency

Conversation

@vhinayindia

Copy link
Copy Markdown

Fixes #542. When throws is false, async readJson now returns null for file-read errors as well as invalid JSON, matching readJsonSync. Default error behavior is unchanged. Callback and Promise cases are covered.

Validation: focused JSON tests (15 passing), node test.mjs, Standard on the changed JavaScript files, and git diff --check. In a CommonJS suite comparison with two Windows root-target tests omitted because they write outside the workspace, the pristine base had 536 passing / 7 pending / 120 failing; this patch had 539 passing / 7 pending / 120 failing. Both runs had the same 115 symlink-creation EPERM failures and 5 cleanup double-callback failures after symlink setup failed. The patch adds three passing regression tests. Those two omitted tests were not included in the baseline comparison.

@RyanZim

RyanZim commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

If this change is to be made, it should be made directly in https://github.com/jprichardson/node-jsonfile (which I also maintain), not done as a wrapper here in fs-extra. Sorry to have to close this.

@RyanZim RyanZim closed this Oct 9, 2026
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.

Inconsistency between readJson and readJsonSync when file does not exist

2 participants