From 67d2b4d99abc81fac1f191edf24e54b34cf0eeca Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 10 Sep 2023 08:31:40 +0100 Subject: [PATCH] perf: use `node:` prefix to bypass require.cache call for builtins See https://github.com/fastify/fastify-static/pull/407 --- test/integration.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration.test.js b/test/integration.test.js index 31b7072..8997241 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -41,7 +41,7 @@ test('cannot exceed body limit', (t) => { if (err) tap.error(err) fastify.server.unref() - const payload = require('crypto').randomBytes(128).toString('hex') + const payload = require('node:crypto').randomBytes(128).toString('hex') fastify.inject({ path: '/limited', method: 'POST', ...formAutoContent({ foo: payload }) }, (err, response) => { t.error(err) t.equal(response.statusCode, 413) @@ -71,7 +71,7 @@ test('cannot exceed body limit when Content-Length is not available', (t) => { fastify.server.unref() let sent = false - const payload = require('stream').Readable({ + const payload = require('node:stream').Readable({ read: function () { this.push(sent ? null : Buffer.alloc(70000, 'a')) sent = true @@ -98,7 +98,7 @@ test('cannot exceed body limit set on Fastify instance', (t) => { if (err) tap.error(err) fastify.server.unref() - const payload = require('crypto').randomBytes(128).toString('hex') + const payload = require('node:crypto').randomBytes(128).toString('hex') fastify.inject({ path: '/limited', method: 'POST', ...formAutoContent({ foo: payload }) }, (err, response) => { t.error(err) t.equal(response.statusCode, 413) @@ -120,7 +120,7 @@ test('plugin bodyLimit should overwrite Fastify instance bodyLimit', (t) => { if (err) tap.error(err) fastify.server.unref() - const payload = require('crypto').randomBytes(128).toString('hex') + const payload = require('node:crypto').randomBytes(128).toString('hex') fastify.inject({ path: '/limited', method: 'POST', ...formAutoContent({ foo: payload }) }, (err, response) => { t.error(err) t.equal(response.statusCode, 413)