fix: guard process.memoryUsage call with typeof check for browser compatibility#9895
Open
ViniciusDev26 wants to merge 3 commits intovitest-dev:mainfrom
Open
fix: guard process.memoryUsage call with typeof check for browser compatibility#9895ViniciusDev26 wants to merge 3 commits intovitest-dev:mainfrom
ViniciusDev26 wants to merge 3 commits intovitest-dev:mainfrom
Conversation
…patibility Fixes UnhandledRejection when logHeapUsage is true in browser environments where process is a polyfill without memoryUsage.
…sage is unavailable
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
sheremet-va
requested changes
Mar 18, 2026
Member
sheremet-va
left a comment
There was a problem hiding this comment.
In environments that don't support memoryUsage, we wanted to use performance.measureUserAgentSpecificMemory as mentioned in the comment: #6500 (comment)
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.
Fixes UnhandledRejection when logHeapUsage is true in browser environments where process is a polyfill without memoryUsage.
Description
Guard process.memoryUsage calls with a typeof check before invoking it, preventing an UnhandledRejection crash when logHeapUsage: true is set in environments where process is a polyfill without memoryUsage (e.g. browser mode).
Resolves #6500
The previous check (typeof process !== 'undefined') only verified that process existed, but not that memoryUsage was actually a
function. In browser environments, process is polyfilled but memoryUsage is not available, causing the call to throw. The fix changes
both guards in onAfterRunSuite and onAfterRunTask to typeof process?.memoryUsage === 'function'.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.