Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! fixup! src: fix timing of snapshot serialize callback
  • Loading branch information
joyeecheung committed Oct 27, 2025
commit d6d46594f8e892b85b13d41542e2d5ec0b67938e
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ const { internalBinding } = require('internal/test/binding');
const { getGenericUsageCount } = internalBinding('debug');
const assert = require('assert');

const initialCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
const initialUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
const initialZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
const buffer = Buffer.allocUnsafe(Buffer.poolSize + 1);
assert.strictEqual(buffer.every((b) => b === 0), true);
const newCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
assert.notStrictEqual(newCount, initialCount);
assert(buffer.every((b) => b === 0));
const newUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
const newZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
assert.strictEqual(newUninitializedCount, initialUninitializedCount);
assert.notStrictEqual(newZeroFilledCount, initialZeroFilledCount);
11 changes: 7 additions & 4 deletions test/parallel/test-buffer-alloc-unsafe-is-uninitialized.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ const { internalBinding } = require('internal/test/binding');
const { getGenericUsageCount } = internalBinding('debug');
const assert = require('assert');

const initialCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
const initialUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
const initialZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
Buffer.allocUnsafe(Buffer.poolSize + 1);
// We can't reliably check the contents of the buffer here because the OS or memory allocator
// used might zero-fill memory for us, or they might happen to return reused memory that was
// previously used by a process that zero-filled it.
const newCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
assert.notStrictEqual(newCount, initialCount);
// previously used by a process that zero-filled it. So instead we just check the usage counts.
const newUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
const newZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
assert.notStrictEqual(newUninitializedCount, initialUninitializedCount);
assert.strictEqual(newZeroFilledCount, initialZeroFilledCount);
Loading