Fix dashboard runtime crash on Node.js v24.0.0 and v25.x (removed Buffer.SlowBuffer)#89
Open
a-magdy wants to merge 3 commits into
Open
Fix dashboard runtime crash on Node.js v24.0.0 and v25.x (removed Buffer.SlowBuffer)#89a-magdy wants to merge 3 commits into
a-magdy wants to merge 3 commits into
Conversation
The dashboard crashes at runtime with:
TypeError: Cannot read properties of undefined (reading 'prototype')
at node_modules/buffer-equal-constant-time/index.js
This is caused by buffer-equal-constant-time@1.0.1 (a transitive dep of
jsonwebtoken via @azure/msal-node via @azure/identity) referencing
`require('buffer').SlowBuffer.prototype`. SlowBuffer was deprecated long
ago and has been removed from Node.js, so the property access throws.
Patch the offending file via patch-package so the fix is reproducible
across npm installs:
- Treat SlowBuffer as optional, only mutate it when present.
- Wire `patch-package` into the `postinstall` script.
Also harden .gitignore at the repo root to ignore .DS_Store and any
local .env files (the dashboard .env was previously only ignored under
src/dashboard).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds src/dashboard/patches/README.md explaining what each patch does and why, and a short pointer from the top-level README so contributors notice the patch step the first time they run `npm install`. Refs #1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree |
The patch applies via the postinstall hook regardless of package manager (npm/yarn/pnpm/bun), so 'npm install' was misleading. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important
Fixes a runtime crash on Node.js v24.0.0 and v25.x.
Node v24.0.1 through v24.x is unaffected (the runtime team restored
SlowBufferafter the accidental v24.0.0 removal). The patch is a no-op on Node versions that still exposeSlowBuffer.Closes #88
Problem
After
npm install && npm run dev, every page returns HTTP 500 with:The crash chain:
services/cosmos-db-service.ts→@azure/identity→@azure/msal-node→jsonwebtoken→jws→jwa→buffer-equal-constant-time@1.0.1buffer-equal-constant-timeis unmaintained (last release 2014) and referencesrequire('buffer').SlowBuffer.prototypeat module top level.Buffer.SlowBufferwas deprecated in Node.js v6 and has since been removed from thebuffermodule, so the property access throws as soon as the module is required.See #88 for the full diagnosis.
Fix
Use
patch-packageto keep a small reviewable diff against the offending file undersrc/dashboard/patches/, and wirepatch-packageintopostinstallso the patch reapplies after everynpm install. The patched code treatsSlowBufferas optional — behaviour is unchanged on older Node versions, and the module loads cleanly on newer ones.Files
src/dashboard/package.jsonpatch-packagedevDep +"postinstall": "patch-package"script.src/dashboard/package-lock.jsonpatch-package's own deps plus minor dedup of sharedljharb/*packages.src/dashboard/patches/buffer-equal-constant-time+1.0.1.patchSlowBufferaccess optional.src/dashboard/patches/README.mdREADME.md.gitignore(root).DS_Storeand*.envfiles at the repo root. The dashboard.envwas previously only ignored undersrc/dashboard/, so a token at the repo root could be committed by accident.Verification
npm install→patch-packagereportsbuffer-equal-constant-time@1.0.1 ✔npm run dev→GET /returns 200npm run build→ succeedsRisk
Low. The patch only modifies one file inside
node_modules, gated onSlowBufferbeing defined, so it is a no-op on older Node releases.Context — why now?
This isn't a regression in the dashboard; the Node.js runtime moved underneath it after
mainwas last touched.SlowBufferdeprecated (DEP0030, doc-only).SlowBufferwas accidentally removed from thebuffermodule — the first version that breaks the dashboard.SlowBufferisundefinedagain (verified empirically on v25.9.0).Last commit on upstream
mainis01ef37dfrom 2025-07-29, so none of this had happened yet — the maintainers couldn't have seen the failure.