Skip to content

Commit

Permalink
perf: use node: prefix to bypass require.cache call for builtins (#144
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Sep 10, 2023
1 parent 1ee7f23 commit 3765a74
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 3765a74

Please sign in to comment.