diff --git a/src/macros.h b/src/macros.h index 1c1a7c445..b46a8752a 100644 --- a/src/macros.h +++ b/src/macros.h @@ -125,7 +125,7 @@ inline bool OtherIsInt(Napi::Number source) { if ((argc != 0) && (passed_argv != NULL)) {\ args.assign(passed_argv, passed_argv + argc);\ }\ - Napi::Value res = (callback).MakeCallback(Napi::Value(context), args); \ + Napi::Value res = (callback).Call(Napi::Value(context), args); \ if (res.IsEmpty()) return __VA_ARGS__; #define WORK_DEFINITION(name) \ diff --git a/test/async_calls.test.js b/test/async_calls.test.js new file mode 100644 index 000000000..9ce29a730 --- /dev/null +++ b/test/async_calls.test.js @@ -0,0 +1,42 @@ +"use strict" + +var sqlite3 = require('..'); +const assert = require("assert"); +const { createHook, executionAsyncId } = require("async_hooks"); + + +describe('async_hooks', function() { + let db; + let dbId; + let asyncHook; + + beforeEach(function() { + db = new sqlite3.Database(':memory:'); + + asyncHook = createHook({ + init(asyncId, type) { + if (dbId == null && type.startsWith("sqlite3.")) { + dbId = asyncId; + } + } + }).enable(); + }); + + it('should support performance measuring with async hooks', function(done) { + db.run("DROP TABLE user", () => { + const cbId = executionAsyncId(); + assert.strictEqual(cbId, dbId); + done(); + }); + }); + + afterEach(function() { + if (asyncHook != null) { + asyncHook.disable(); + } + dbId = null; + if (db != null) { + db.close(); + } + }); +}); \ No newline at end of file