GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: localStorage exception in Node 25+ by tophf · Pull Request #1880 · jantimon/html-webpack-plugin

Conversation

@tophf

@tophf tophf commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

The problem I'm fixing here is that Node 25+ throws on reading localStorage that occurs implicitly in ...global:

    const vmContext = vm.createContext({
      ...global,

My fix is to use a "meta" clone via Object.getOwnPropertyDescriptors + Object.defineProperties, which copies literally every global and is arguably what f269fc0 intended to achieve. Hopefully there are no secret/sensitive globals used by this plugin.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@alexander-akait

alexander-akait commented Nov 13, 2025

Copy link
Copy Markdown
Collaborator

Sounds like a regression on Node.js side

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait alexander-akait mentioned this pull request Nov 13, 2025
Regression 25.2.0 - Cannot initialize local storage without a --localstorage-file path nodejs/node#60704
Closed
@alexander-akait

alexander-akait commented Nov 13, 2025

Copy link
Copy Markdown
Collaborator

Reported - nodejs/node#60704 let's wait an answer

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slorber

slorber commented Nov 13, 2025

Copy link
Copy Markdown

This also prevents Docusaurus dev server from starting: meta/docusaurus#11545

CleanShot 2025-11-13 at 17 05 37@2x
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slorber

slorber commented Nov 13, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

I tried this patch locally for Docusaurus, and it didn't work under Node 25.2:

×   Error: require is not defined
  │ 
  │   - dev.html.template.ejs:63
  │     /projects/docusaurus/packages/docusaurus/lib/webpack/templates/dev.html.template.ejs:63:1
  │ 

I tried adding back the "require" removed, leading to another error:

×   Error: __webpack_require__ is not defined
  │ 
  │ 
  │   - eval
  │ 
  │   - dev.html.template.ejs:10 data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;
  │     /projects/docusaurus/packages/docusaurus/lib/webpack/templates/dev.html.template.ejs:10:1

I tried adding back everything you removed and keeping the spread:

...Object.defineProperties({}, Object.getOwnPropertyDescriptors(global))
×   Error: Value of "this" must be of type nullish or must be the global object
  │ 
  │   - exposed-window-or-worker:114 global.cryptoThisCheck
  │     node:internal/bootstrap/web/exposed-window-or-worker:114:15

No idea how to fix it.


Need to double check, but I also think it fails on Node 24:

×   TypeError: Cannot set property crypto of #<Object> which has only a getter
  │ 
  │   - Object.assign

Repro?:

git clone [email protected]:facebook/docusaurus.git
cd docusaurus
yarn install
yarn start:website
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slorber slorber mentioned this pull request Nov 13, 2025
docusaurus build broken with NodeJS 25 meta/docusaurus#11545
Closed
5 of 7 tasks
@alexander-akait

alexander-akait commented Nov 13, 2025

Copy link
Copy Markdown
Collaborator

@slorber Yeah, I think we will need to wait Node.js answer here, we need to pass globals here, technically we can filter as a workaround, but I still think it is a Node.js regression, let's wait an answer from them

slorber reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tophf

tophf commented Nov 13, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

This change in node is spec-compliant, so it's unlikely they'll revert it.

I've re-worked the fix to handle one problem that turned out to be caused by eval, however I couldn't ensure the test completes locally because eslint kept finding dozens of [objectively present] violations in the existing code that I didn't change and some of test:only suites claimed unexpected values while they looked exactly like the expected one.

The test:only has succeeded after I disabled git's autocrlf for the repo.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov-commenter

codecov-commenter commented Nov 14, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@6ef547a). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1880   +/-   ##
=======================================
  Coverage        ?   92.38%           
=======================================
  Files           ?       18           
  Lines           ?      749           
  Branches        ?      209           
=======================================
  Hits            ?      692           
  Misses          ?       54           
  Partials        ?        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented Nov 14, 2025

Copy link
Copy Markdown
Collaborator

@tophf I still think it is a bug and should be reverted, any way I am fine with these changes too, do can fix eslint problem?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tophf

tophf commented Nov 14, 2025

Copy link
Copy Markdown
Contributor Author

fix eslint problem

In this PR? But that code is completely unrelated, so it'd be weird to change it here. What if I just exclude the file from eslint checks altogether and someone will deal with those issues separately?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented Nov 14, 2025

Copy link
Copy Markdown
Collaborator

@tophf I mean fix prettier - https://github.com/jantimon/html-webpack-plugin/actions/runs/19344385065/job/55400556942?pr=1880

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tophf

tophf commented Nov 14, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Yeah, I saw that. Thing is, it doesn't say what's wrong. If the project is using prettier I would expect it to be applied automatically without me doing anything. Should I run prettier explicitly myself?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tophf
fix: localStorage exception in Node 25+
a88940e
@tophf

tophf commented Nov 14, 2025

Copy link
Copy Markdown
Contributor Author

Okay, I found and ran fix:prettier which fixed lint:prettier test, but I still can't commit the change due to lint:js which finds problems in this file that aren't mine, so I've just disabled the pre-commit hook and force-pushed the changes anyway.

alexander-akait reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@botantony botantony mentioned this pull request Nov 15, 2025
unisonlang 1.0.0 Homebrew/homebrew-core#254509
Merged
alexander-akait
alexander-akait approved these changes Nov 18, 2025
View reviewed changes
@alexander-akait

alexander-akait commented Nov 18, 2025

Copy link
Copy Markdown
Collaborator

@tophf Thanks for this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait merged commit a25aa2e into jantimon:main Nov 18, 2025
35 of 39 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@tophf
tophf deleted the patch-1 branch November 18, 2025 13:00
@chenjiahan chenjiahan mentioned this pull request Mar 26, 2026
fix: localStorage exception in Node 25+ rstackjs/html-rspack-plugin#60
Merged
@Marukome0743 Marukome0743 mentioned this pull request Apr 17, 2026
fix: provide module/exports in VM sandbox for Node.js 25+ compatibility #1889
Merged
alexander-akait pushed a commit that referenced this pull request Apr 17, 2026
@Marukome0743
fix: provide module/exports in VM sandbox for Node.js 25+ compatibili…
c862830
…ty (#1889)

Templates whose child compilation output is a CommonJS module (for
example Rspack's HtmlWebpackPlugin child compilation, which wraps the
evaluated template in `module.exports = ...`) were failing at evaluation
time with `ReferenceError: module is not defined` under Node.js 25+.

In 5.6.5 the VM context was switched away from a `...global` spread
because spreading `global` on Node 25 throws once `localStorage` is
touched without `--localstorage-file`. The replacement clone only
exposes the standard globals plus `require`, so any CommonJS-wrapped
source that assigned to `module.exports` hit the ReferenceError.

Provide a throwaway `module = { exports: {} }` pair (plus `exports`
aliasing it) in the sandbox so CommonJS-style outputs can evaluate
without assuming the host Node version populates them.

Refs: PR #1880, meta/docusaurus#11545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alexander-akait alexander-akait alexander-akait approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tophf @alexander-akait @slorber @codecov-commenter
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.