Skip to content

Commit 08c75f9

Browse files
rochdevtlhunter
authored andcommitted
handle ffi errors
1 parent 5407315 commit 08c75f9

File tree

1 file changed

+14
-11
lines changed
  • benchmark/sirun/plugin-koa/internal-tracer

1 file changed

+14
-11
lines changed

benchmark/sirun/plugin-koa/internal-tracer/encoder.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,20 @@ class Encoder {
183183
// TODO: Use node:ffi when it lands.
184184
// https://github.com/nodejs/node/pull/46905
185185
flushFfi (data, done) {
186-
const path = require('path')
187-
const { getNativeFunction, getBufferPointer } = require('sbffi')
188-
const libPath = path.normalize(
189-
path.join(__dirname, '../../../../collector/target/release/libffi.dylib')
190-
)
191-
const submit = getNativeFunction(libPath, 'submit', 'uint32_t', ['uint32_t', 'uint8_t *'])
192-
const ptr = getBufferPointer(data)
193-
194-
submit(data.length, ptr)
195-
196-
done()
186+
try {
187+
const path = require('path')
188+
const { getNativeFunction, getBufferPointer } = require('sbffi')
189+
const libPath = path.normalize(
190+
path.join(__dirname, '../../../../collector/target/release/libffi.dylib')
191+
)
192+
const submit = getNativeFunction(libPath, 'submit', 'uint32_t', ['uint32_t', 'uint8_t *'])
193+
const ptr = getBufferPointer(data)
194+
195+
submit(data.length, ptr)
196+
done()
197+
} catch (e) {
198+
done(e)
199+
}
197200
}
198201

199202
reset () {

0 commit comments

Comments
 (0)