Skip to content

test: raise memory thresholds in memoryUsage namespace test - #299

Merged
mcollina merged 1 commit into
mainfrom
test/memory-usage-thresholds
Sep 13, 2026
Merged

mcollina merged 1 commit into
mainfrom
test/memory-usage-thresholds

Conversation

@Tony133

@Tony133 Tony133 commented Sep 8, 2026

Copy link
Copy Markdown
Member

Proposal:

The memoryUsage name space test registers the plugin with maxRssBytes: 100000000 (100 MB) and a pressureHandler that asserts it is never called. That threshold is too close to the actual footprint of a modern Node.js process: on Linux with Node 22 the RSS at that point of the test file is already ~95 MB, and on macOS with Node 26 (added to the matrix by fastify/workflows v7.0.0) with coverage enabled it exceeds 100 MB.

When that happens the plugin invokes the pressureHandler, t.assert.ok(false) throws inside the hook, Fastify turns it into a 500 and the test fails with an opaque message:

    AssertionError [ERR_ASSERTION]: 500 == 200
        at test/index.test.js:283:18

This is what blocks #296.

The test only verifies that the fastify.memoryUsage() namespace works and that no pressure is detected; it does not exercise the thresholds. This PR:

  • raises maxHeapUsedBytes / maxRssBytes to 1e9 and maxEventLoopUtilization to 0.99 so they cannot be hit by the runtime footprint
  • adds a message to the t.assert.ok(false) reporting which metric triggered the handler and with which value
  • passes the response body as the message of the status code assertion, so that message actually shows up in the test output instead of being swallowed by the 500 response

Note:

  • No changes to index.js, behaviour under test is unchanged.

@jean-michelet

Copy link
Copy Markdown
Member

Sounds good, let's wait for Matteo review imo.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
mcollina merged commit 6b29b8d into main Sep 13, 2026
17 checks passed
@mcollina
mcollina deleted the test/memory-usage-thresholds branch September 13, 2026 19:42
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.

3 participants