MCPcopy Index your code
hub / github.com/nodejs/node / assertInvalidCallbackBehaviorAborts

Function assertInvalidCallbackBehaviorAborts

test/ffi/test-ffi-calls.js:329–350  ·  view source on GitHub ↗
(callbackBody, message)

Source from the content-addressed store, hash-verified

327}
328
329function assertInvalidCallbackBehaviorAborts(callbackBody, message) {
330 const { stderr, status, signal } = spawnSync(process.execPath, [
331 '--experimental-ffi',
332 '-e',
333 `'use strict';
334const ffi = require('node:ffi');
335const { fixtureSymbols, libraryPath } = require(${JSON.stringify(require.resolve('./ffi-test-common'))});
336const { lib, functions } = ffi.dlopen(libraryPath, fixtureSymbols);
337const callback = lib.registerCallback(
338 { arguments: ['i32'], return: 'i32' },
339 () => { ${callbackBody} },
340);
341functions.call_int_callback(callback, 21);`,
342 ], {
343 encoding: 'utf8',
344 });
345
346 assert.ok(common.nodeProcessAborted(status, signal),
347 `status: ${status}, signal: ${signal}
348stderr: ${stderr}`);
349 assert.ok(message.test(stderr), stderr);
350}
351
352function assertCrossThreadCallbackAbort() {
353 const workerSource = `

Callers 1

test-ffi-calls.jsFile · 0.85

Calls 4

spawnSyncFunction · 0.50
resolveMethod · 0.45
okMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…