From e9ce116fd31c776f2acb4448a11a8cc2df7ada41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Rzepecki?= Date: Thu, 1 Feb 2024 21:38:52 -0500 Subject: [PATCH] feat: Instrument named const and exported lambdas --- src/hooks/__tests__/instrument.test.ts | 211 ++++- src/hooks/instrument.ts | 109 ++- src/registry.ts | 2 +- src/util/isId.ts | 6 +- test/__snapshots__/httpClient.test.ts.snap | 861 ++++++++++++++++++- test/__snapshots__/mysql.test.ts.snap | 709 +++++++++++++++- test/__snapshots__/sqlite.test.ts.snap | 913 ++++++++++++++++++--- 7 files changed, 2646 insertions(+), 165 deletions(-) diff --git a/src/hooks/__tests__/instrument.test.ts b/src/hooks/__tests__/instrument.test.ts index a448fd44..456b1aea 100644 --- a/src/hooks/__tests__/instrument.test.ts +++ b/src/hooks/__tests__/instrument.test.ts @@ -102,10 +102,219 @@ describe(instrument.transform, () => { `, ); }); + + it("instruments const lambdas", () => { + const program = parse( + ` + const outer = arg => arg + 42; + + export const testFun = arg => { + var s42 = y => y - 42; + let s43 = y => y - 43; + const inner = x => s42(x) * 2; + return inner(arg); + }; + `, + { loc: true, source: fixAbsPath("/test/test.js"), module: true }, + ); + + expectProgram( + instrument.transform(program), + ` + const __appmapFunctionRegistry = [ + { + "async": false, + "generator": false, + "id": "outer", + "params": [ + { + "type": "Identifier", + "name": "arg", + }, + ], + "location": { + "path": "test.js", + "lineno": 2, + }, + "klassOrFile": "test", + "static": true, + }, + { + "async": false, + "generator": false, + "id": "inner", + "params": [ + { + "type": "Identifier", + "name": "x", + }, + ], + "location": { + "path": "test.js", + "lineno": 7, + }, + "klassOrFile": "test", + "static": true, + }, + { + "async": false, + "generator": false, + "id": "testFun", + "params": [ + { + "type": "Identifier", + "name": "arg", + }, + ], + "location": { + "path": "test.js", + "lineno": 4, + }, + "klassOrFile": "test", + "static": true, + }, + ]; + + const outer = (...args) => global.AppMapRecordHook.call( + undefined, + (arg) => arg + 42, + args, + __appmapFunctionRegistry[0], + ); + + export const testFun = (...args) => + global.AppMapRecordHook.call( + undefined, + (arg) => { + var s42 = y => y - 42; + let s43 = y => y - 43; + const inner = (...args) => + global.AppMapRecordHook.call( + undefined, + (x) => s42(x) * 2, + args, + __appmapFunctionRegistry[1], + ); + return inner(arg); + }, + args, + __appmapFunctionRegistry[2], + ); + `, + ); + }); + + it("instruments CommonJS exported named lambdas", () => { + const program = parse( + ` + exports.testFun = arg => { + const inner = x => x *2; + return inner(arg); + }; + `, + { loc: true, source: fixAbsPath("/test/test.js"), module: true }, + ); + + expectProgram( + instrument.transform(program), + ` + const __appmapFunctionRegistry = [ + { + "async": false, + "generator": false, + "id": "inner", + "params": [ + { + "type": "Identifier", + "name": "x", + }, + ], + "location": { + "path": "test.js", + "lineno": 3, + }, + "klassOrFile": "test", + "static": true, + }, + { + "async": false, + "generator": false, + "id": "testFun", + "params": [ + { + "type": "Identifier", + "name": "arg", + }, + ], + "location": { + "path": "test.js", + "lineno": 2, + }, + "klassOrFile": "test", + "static": true, + }, + ]; + + exports.testFun = (...args) => + global.AppMapRecordHook.call( + undefined, + (arg) => { + const inner = (...args) => + global.AppMapRecordHook.call( + undefined, + (x) => x * 2, + args, + __appmapFunctionRegistry[0], + ); + return inner(arg); + }, + args, + __appmapFunctionRegistry[1], + ); + `, + ); + }); + + it("instruments const lambdas which are later CommonJS exported", () => { + const program = parse( + ` + const testFun = x => x * 2 + + exports.testFun = testFun; + `, + { loc: true, source: fixAbsPath("/test/test.js"), module: true }, + ); + + expectProgram( + instrument.transform(program), + ` + const __appmapFunctionRegistry = [{ + "async": false, + "generator": false, + "id": "testFun", + "params": [{ + "type": "Identifier", + "name": "x" + }], + "location": { + "path": "test.js", + "lineno": 2 + }, + "klassOrFile": "test", + "static": true + }]; + + const testFun = (...args) => global.AppMapRecordHook.call(undefined, x => x * 2, + args, __appmapFunctionRegistry[0]); + + exports.testFun = testFun; + `, + ); + }); }); function expectProgram(actual: ESTree.Program, expected: string) { - expect(generate(actual)).toEqual(generate(parse(expected))); + expect(generate(actual)).toEqual(generate(parse(expected, { module: true }))); } jest.mock("../../config"); diff --git a/src/hooks/instrument.ts b/src/hooks/instrument.ts index 1f0cae99..d7159d7b 100644 --- a/src/hooks/instrument.ts +++ b/src/hooks/instrument.ts @@ -21,6 +21,7 @@ import { } from "../generate"; import { FunctionInfo, SourceLocation, createFunctionInfo, createMethodInfo } from "../registry"; import findLast from "../util/findLast"; +import { isId } from "../util/isId"; const debug = debuglog("appmap:instrument"); @@ -47,7 +48,7 @@ export function transform(program: ESTree.Program, sourceMap?: SourceMapConsumer const location = locate(fun); if (!location) return; // don't instrument generated code - fun.body = wrapWithRecord(fun, createFunctionInfo(fun, location), false); + fun.body = wrapFunction(fun, createFunctionInfo(fun, location), false); }, MethodDefinition(method: ESTree.MethodDefinition, _: unknown, ancestors: ESTree.Node[]) { @@ -71,12 +72,49 @@ export function transform(program: ESTree.Program, sourceMap?: SourceMapConsumer if (!location) return; // don't instrument generated code debug(`Instrumenting ${qname}`); - method.value.body = wrapWithRecord( + method.value.body = wrapFunction( { ...method.value }, createMethodInfo(method, klass, location), method.kind === "constructor", ); }, + + // instrument arrow functions + ArrowFunctionExpression(fun: ESTree.ArrowFunctionExpression, _, ancestors: ESTree.Node[]) { + const location = locate(fun); + if (!location) return; // don't instrument generated code + + const [declaration, declarator] = ancestors.slice(-3); + switch (declarator.type) { + // instrument consts + case "VariableDeclarator": { + if (!(declaration.type === "VariableDeclaration" && declaration.kind === "const")) return; + const { id } = declarator; + if (!isId(id)) return; + if (pkg?.exclude?.includes(id.name)) return; + assert(declarator.init === fun); + + debug(`Instrumenting ${id.name}`); + declarator.init = wrapLambda( + fun, + createFunctionInfo({ ...fun, id, generator: false }, location), + ); + break; + } + // instrument CommonJS exports + case "AssignmentExpression": { + const id = exportName(declarator.left); + if (!id || pkg?.exclude?.includes(id.name)) return; + + debug(`Instrumenting ${id.name}`); + declarator.right = wrapLambda( + fun, + createFunctionInfo({ ...fun, id, generator: false }, location), + ); + break; + } + } + }, }); if (transformedFunctionInfos.length === 0) return program; @@ -101,6 +139,25 @@ export function transform(program: ESTree.Program, sourceMap?: SourceMapConsumer return program; } +function wrapLambda( + lambda: ESTree.ArrowFunctionExpression, + functionInfo: FunctionInfo, +): ESTree.ArrowFunctionExpression { + const args = identifier("args"); + return { + type: "ArrowFunctionExpression", + async: false, + expression: false, + params: [ + { + type: "RestElement", + argument: args, + }, + ], + body: wrapCallable(lambda, functionInfo, identifier("undefined"), args), + }; +} + function makeLocator( sourceMap?: SourceMapConsumer, ): (node: ESTree.Node) => SourceLocation | undefined { @@ -131,15 +188,33 @@ function objectLiteralExpression(obj: object) { return parsed.body[0].expression; } -function wrapWithRecord( +function wrapCallable( + fd: ESTree.FunctionDeclaration | ESTree.FunctionExpression | ESTree.ArrowFunctionExpression, + functionInfo: FunctionInfo, + thisArg: ESTree.Expression, + argsArg: ESTree.Expression, +): ESTree.CallExpression { + const functionArgument: ESTree.Expression = + fd.type === "ArrowFunctionExpression" + ? fd + : fd.generator + ? { ...fd, type: "FunctionExpression" } + : toArrowFunction(fd); + return call_( + memberId("global", "AppMapRecordHook", "call"), + thisArg, + functionArgument, + argsArg, + member(__appmapFunctionRegistryIdentifier, literal(addTransformedFunctionInfo(functionInfo))), + ); +} + +function wrapFunction( fd: ESTree.FunctionDeclaration | ESTree.FunctionExpression, functionInfo: FunctionInfo, thisIsUndefined: boolean, -) { +): ESTree.BlockStatement { const statement = fd.generator ? yieldStar : ret; - const functionArgument: ESTree.Expression = fd.generator - ? { ...fd, type: "FunctionExpression" } - : toArrowFunction(fd); const wrapped: ESTree.BlockStatement = { type: "BlockStatement", @@ -149,16 +224,7 @@ function wrapWithRecord( // If it's a generator function then pass it as a generator function and yield* the result: // yield* global.AppMapRecordHook(this|undefined, function* f() {...}, arguments, __appmapFunctionRegistry[i]) statement( - call_( - memberId("global", "AppMapRecordHook", "call"), - thisIsUndefined ? identifier("undefined") : this_, - functionArgument, - args_, - member( - __appmapFunctionRegistryIdentifier, - literal(addTransformedFunctionInfo(functionInfo)), - ), - ), + wrapCallable(fd, functionInfo, thisIsUndefined ? identifier("undefined") : this_, args_), ), ], }; @@ -191,3 +257,12 @@ function methodHasName( ): method is ESTree.MethodDefinition & { key: { name: string } } { return method.key !== null && "name" in method.key; } + +// returns the export name if expr is a CommonJS export member +function exportName(expr: ESTree.Expression): ESTree.Identifier | undefined { + if (expr.type === "MemberExpression" && isId(expr.object, "exports")) { + const { property } = expr; + if (isId(property)) return property; + } + return undefined; +} diff --git a/src/registry.ts b/src/registry.ts index 1f60f97f..02d7c792 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -21,7 +21,7 @@ export interface FunctionInfo { } export function createFunctionInfo( - fun: ESTree.FunctionDeclaration & { + fun: Omit & { id: ESTree.Identifier; }, location: SourceLocation, diff --git a/src/util/isId.ts b/src/util/isId.ts index 4ac7d983..911426cb 100644 --- a/src/util/isId.ts +++ b/src/util/isId.ts @@ -1,5 +1,7 @@ import type { ESTree } from "meriyah"; -export function isId(node: ESTree.Node | null, name: string) { - return node?.type === "Identifier" && node.name === name; +export function isId(node: ESTree.Node | null, name?: string): node is ESTree.Identifier { + if (node?.type !== "Identifier") return false; + if (name && node.name !== name) return false; + return true; } diff --git a/test/__snapshots__/httpClient.test.ts.snap b/test/__snapshots__/httpClient.test.ts.snap index 0377ccf9..f090a9a9 100644 --- a/test/__snapshots__/httpClient.test.ts.snap +++ b/test/__snapshots__/httpClient.test.ts.snap @@ -187,6 +187,12 @@ exports[`mapping http client requests 1`] = ` "static": true, "type": "function", }, + { + "location": "index.js:6", + "name": "consume", + "static": true, + "type": "function", + }, ], "name": "index", "type": "class", @@ -197,14 +203,50 @@ exports[`mapping http client requests 1`] = ` }, ], "eventUpdates": { - "2": { + "12": { "elapsed": 31.337, "event": "return", - "id": 2, + "id": 12, + "parent_id": 11, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "3": { + "elapsed": 31.337, + "event": "return", + "id": 3, + "parent_id": 2, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "4": { + "elapsed": 31.337, + "event": "return", + "id": 4, "parent_id": 1, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "8": { + "elapsed": 31.337, + "event": "return", + "id": 8, + "parent_id": 7, + "return_value": { + "class": "Promise", + "object_id": 5, "value": "Promise { undefined }", }, "thread_id": 0, @@ -222,14 +264,117 @@ exports[`mapping http client requests 1`] = ` "static": true, "thread_id": 0, }, + { + "defined_class": "index", + "event": "call", + "id": 2, + "lineno": 6, + "method_id": "consume", + "parameters": [ + { + "class": "ClientRequest", + "name": "request", + "object_id": 1, + "value": "ClientRequest { + _events: [Object: null prototype] { finish: [Function (anonymous)] }, + _eventsCount: 1, + _maxListeners: undefined, + outputData: [], + outputSize: 0, + writable: true, + destroyed: false, + _last: false, + chunkedEncoding: false, + shouldKeepAlive: true, + maxRequestsOnConnectionReached: false, + _defaultKeepAlive: true, + useChunkedEncodingByDefault: false, + sendDate: false, + _removedConnection: false, + _removedContLen: false, + _removedTE: false, + strictContentLength: false, + _contentLength: null, + _hasBody: true, + _trailer: '', + finished: false, + _headerSent: false, + _closed: false, + socket: null, + _header: null, + _keepAliveTimeout: 0, + _onPendingData: [Function: nop], + agent: Agent { + _events: [Object: null prototype], + _eventsCount: 2, + _maxListeners: undefined, + defaultPort: 80, + protocol: 'http:', + options: [Object: null prototype], + requests: [Object: null prototype] {}, + sockets: [Object: null prototype], + freeSockets: [Object: null prototype] {}, + keepAliveMsecs: 1000, + keepAlive: true, + maxSockets: Infinity, + maxFreeSockets: 256, + scheduling: 'lifo', + maxTotalSockets: Infinity, + totalSocketCount: 1, + [Symbol(kCapture)]: false + }, + socketPath: undefined, + method: 'GET', + maxHeaderSize: undefined, + insecureHTTPParser: undefined, + joinDuplicateHeaders: undefined, + path: '/endpoint/one', + _ended: false, + res: null, + aborted: false, + timeoutCb: null, + upgradeOrConnect: false, + parser: null, + maxHeadersCount: null, + reusedSocket: false, + host: 'localhost', + protocol: 'http:', + [Symbol(kCapture)]: false, + [Symbol(kBytesWritten)]: 0, + [Symbol(kNeedDrain)]: false, + [Symbol(corked)]: 0, + [Symbol(kOutHeaders)]: [Object: null prototype] { host: [Array], 'test-header': [Array] }, + [Symbol(errored)]: null, + [Symbol(kHighWaterMark)]: 16384, + [Symbol(kRejectNonStandardBodyWrites)]: false, + [Symbol(kUniqueHeaders)]: null +}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, { "elapsed": 31.337, "event": "return", - "id": 2, + "id": 3, + "parent_id": 2, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 4, "parent_id": 1, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, "value": "Promise { }", }, "thread_id": 0, @@ -244,7 +389,7 @@ exports[`mapping http client requests 1`] = ` "request_method": "GET", "url": "http://localhost:27628/endpoint/one", }, - "id": 3, + "id": 5, "thread_id": 0, }, { @@ -256,8 +401,111 @@ exports[`mapping http client requests 1`] = ` }, "status_code": 200, }, - "id": 4, - "parent_id": 3, + "id": 6, + "parent_id": 5, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 7, + "lineno": 6, + "method_id": "consume", + "parameters": [ + { + "class": "ClientRequest", + "name": "request", + "object_id": 4, + "value": "ClientRequest { + _events: [Object: null prototype] { finish: [Function (anonymous)] }, + _eventsCount: 1, + _maxListeners: undefined, + outputData: [], + outputSize: 0, + writable: true, + destroyed: false, + _last: false, + chunkedEncoding: false, + shouldKeepAlive: true, + maxRequestsOnConnectionReached: false, + _defaultKeepAlive: true, + useChunkedEncodingByDefault: true, + sendDate: false, + _removedConnection: false, + _removedContLen: false, + _removedTE: false, + strictContentLength: false, + _contentLength: null, + _hasBody: true, + _trailer: '', + finished: false, + _headerSent: false, + _closed: false, + socket: null, + _header: null, + _keepAliveTimeout: 0, + _onPendingData: [Function: nop], + agent: Agent { + _events: [Object: null prototype], + _eventsCount: 2, + _maxListeners: undefined, + defaultPort: 80, + protocol: 'http:', + options: [Object: null prototype], + requests: [Object: null prototype] {}, + sockets: [Object: null prototype], + freeSockets: [Object: null prototype] {}, + keepAliveMsecs: 1000, + keepAlive: true, + maxSockets: Infinity, + maxFreeSockets: 256, + scheduling: 'lifo', + maxTotalSockets: Infinity, + totalSocketCount: 1, + [Symbol(kCapture)]: false + }, + socketPath: undefined, + method: 'POST', + maxHeaderSize: undefined, + insecureHTTPParser: undefined, + joinDuplicateHeaders: undefined, + path: '/endpoint/two?p1=v1&p2=v2', + _ended: false, + res: null, + aborted: false, + timeoutCb: null, + upgradeOrConnect: false, + parser: null, + maxHeadersCount: null, + reusedSocket: true, + host: 'localhost', + protocol: 'http:', + [Symbol(kCapture)]: false, + [Symbol(kBytesWritten)]: 0, + [Symbol(kNeedDrain)]: false, + [Symbol(corked)]: 0, + [Symbol(kOutHeaders)]: [Object: null prototype] { 'content-type': [Array], host: [Array] }, + [Symbol(errored)]: null, + [Symbol(kHighWaterMark)]: 16384, + [Symbol(kRejectNonStandardBodyWrites)]: false, + [Symbol(kUniqueHeaders)]: null +}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 8, + "parent_id": 7, + "return_value": { + "class": "Promise", + "object_id": 5, + "value": "Promise { }", + }, "thread_id": 0, }, { @@ -270,7 +518,7 @@ exports[`mapping http client requests 1`] = ` "request_method": "POST", "url": "http://localhost:27628/endpoint/two", }, - "id": 5, + "id": 9, "thread_id": 0, }, { @@ -283,8 +531,114 @@ exports[`mapping http client requests 1`] = ` }, "status_code": 404, }, - "id": 6, - "parent_id": 5, + "id": 10, + "parent_id": 9, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 11, + "lineno": 6, + "method_id": "consume", + "parameters": [ + { + "class": "ClientRequest", + "name": "request", + "object_id": 6, + "value": "ClientRequest { + _events: [Object: null prototype] { finish: [Function (anonymous)] }, + _eventsCount: 1, + _maxListeners: undefined, + outputData: [ [Object] ], + outputSize: 79, + writable: true, + destroyed: false, + _last: true, + chunkedEncoding: false, + shouldKeepAlive: true, + maxRequestsOnConnectionReached: false, + _defaultKeepAlive: true, + useChunkedEncodingByDefault: false, + sendDate: false, + _removedConnection: false, + _removedContLen: false, + _removedTE: false, + strictContentLength: false, + _contentLength: 0, + _hasBody: true, + _trailer: '', + finished: true, + _headerSent: true, + _closed: false, + socket: null, + _header: 'GET /endpoint/three HTTP/1.1\\r\\n' + + 'Host: localhost:27628\\r\\n' + + 'Connection: keep-alive\\r\\n' + + '\\r\\n', + _keepAliveTimeout: 0, + _onPendingData: [Function: nop], + agent: Agent { + _events: [Object: null prototype], + _eventsCount: 2, + _maxListeners: undefined, + defaultPort: 80, + protocol: 'http:', + options: [Object: null prototype], + requests: [Object: null prototype] {}, + sockets: [Object: null prototype], + freeSockets: [Object: null prototype] {}, + keepAliveMsecs: 1000, + keepAlive: true, + maxSockets: Infinity, + maxFreeSockets: 256, + scheduling: 'lifo', + maxTotalSockets: Infinity, + totalSocketCount: 1, + [Symbol(kCapture)]: false + }, + socketPath: undefined, + method: 'GET', + maxHeaderSize: undefined, + insecureHTTPParser: undefined, + joinDuplicateHeaders: undefined, + path: '/endpoint/three', + _ended: false, + res: null, + aborted: false, + timeoutCb: null, + upgradeOrConnect: false, + parser: null, + maxHeadersCount: null, + reusedSocket: true, + host: 'localhost', + protocol: 'http:', + [Symbol(kCapture)]: false, + [Symbol(kBytesWritten)]: 0, + [Symbol(kNeedDrain)]: false, + [Symbol(corked)]: 0, + [Symbol(kOutHeaders)]: [Object: null prototype] { host: [Array] }, + [Symbol(errored)]: null, + [Symbol(kHighWaterMark)]: 16384, + [Symbol(kRejectNonStandardBodyWrites)]: false, + [Symbol(kUniqueHeaders)]: null +}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 12, + "parent_id": 11, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { }", + }, "thread_id": 0, }, { @@ -296,7 +650,7 @@ exports[`mapping http client requests 1`] = ` "request_method": "GET", "url": "http://localhost:27628/endpoint/three", }, - "id": 7, + "id": 13, "thread_id": 0, }, { @@ -309,8 +663,8 @@ exports[`mapping http client requests 1`] = ` }, "status_code": 404, }, - "id": 8, - "parent_id": 7, + "id": 14, + "parent_id": 13, "thread_id": 0, }, ], @@ -355,6 +709,12 @@ exports[`mapping mocked http client requests 1`] = ` "static": true, "type": "function", }, + { + "location": "index.js:6", + "name": "consume", + "static": true, + "type": "function", + }, ], "name": "index", "type": "class", @@ -365,14 +725,50 @@ exports[`mapping mocked http client requests 1`] = ` }, ], "eventUpdates": { - "3": { + "10": { "elapsed": 31.337, "event": "return", - "id": 3, + "id": 10, + "parent_id": 9, + "return_value": { + "class": "Promise", + "object_id": 5, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "14": { + "elapsed": 31.337, + "event": "return", + "id": 14, + "parent_id": 13, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "4": { + "elapsed": 31.337, + "event": "return", + "id": 4, + "parent_id": 3, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "5": { + "elapsed": 31.337, + "event": "return", + "id": 5, "parent_id": 2, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, "value": "Promise { undefined }", }, "thread_id": 0, @@ -401,14 +797,151 @@ exports[`mapping mocked http client requests 1`] = ` "static": true, "thread_id": 0, }, + { + "defined_class": "index", + "event": "call", + "id": 3, + "lineno": 6, + "method_id": "consume", + "parameters": [ + { + "class": "OverriddenClientRequest", + "name": "request", + "object_id": 1, + "value": " OverriddenClientRequest { + _events: [Object: null prototype] { finish: [Function (anonymous)] }, + _eventsCount: 1, + _maxListeners: undefined, + outputData: [], + outputSize: 0, + writable: true, + destroyed: false, + _last: false, + chunkedEncoding: false, + shouldKeepAlive: true, + maxRequestsOnConnectionReached: false, + _defaultKeepAlive: true, + useChunkedEncodingByDefault: true, + sendDate: false, + _removedConnection: false, + _removedContLen: false, + _removedTE: false, + strictContentLength: false, + _contentLength: null, + _hasBody: true, + _trailer: '', + finished: false, + _headerSent: false, + _closed: false, + socket: Socket { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + bufferSize: 0, + writableLength: 0, + writable: true, + readable: true, + pending: false, + destroyed: false, + connecting: true, + _hadError: false, + timeout: 0, + remoteFamily: 'IPv4', + remoteAddress: '127.0.0.1', + localAddress: '127.0.0.1', + remotePort: 27628, + localPort: 27628, + [Symbol(kCapture)]: false + }, + _header: null, + _keepAliveTimeout: 0, + _onPendingData: [Function: nop], + path: '/endpoint/one', + method: undefined, + write: [Function (anonymous)], + end: [Function (anonymous)], + flushHeaders: [Function (anonymous)], + req: [Circular *1], + options: { + protocol: 'http:', + hostname: 'localhost', + hash: '', + search: '', + pathname: '/endpoint/one', + path: '/endpoint/one', + href: 'http://localhost:27628/endpoint/one', + port: 27628, + proto: 'http', + host: 'localhost:27628', + headers: {} + }, + interceptors: [ [Interceptor], [Interceptor], [Interceptor] ], + response: IncomingMessage { + _readableState: [ReadableState], + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + socket: [Socket], + httpVersionMajor: null, + httpVersionMinor: null, + httpVersion: null, + complete: false, + rawHeaders: [], + rawTrailers: [], + joinDuplicateHeaders: false, + aborted: false, + upgrade: null, + url: '', + method: null, + statusCode: null, + statusMessage: null, + client: [Socket], + _consuming: false, + _dumped: false, + [Symbol(kCapture)]: false, + [Symbol(kHeaders)]: null, + [Symbol(kHeadersCount)]: 0, + [Symbol(kTrailers)]: null, + [Symbol(kTrailersCount)]: 0 + }, + requestBodyBuffers: [], + playbackStarted: false, + readyToStartPlaybackOnSocketEvent: false, + [Symbol(kCapture)]: false, + [Symbol(kBytesWritten)]: 0, + [Symbol(kNeedDrain)]: false, + [Symbol(corked)]: 0, + [Symbol(kOutHeaders)]: [Object: null prototype] { 'test-header': [Array] }, + [Symbol(errored)]: null, + [Symbol(kHighWaterMark)]: 16384, + [Symbol(kRejectNonStandardBodyWrites)]: false +}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, { "elapsed": 31.337, "event": "return", - "id": 3, + "id": 4, + "parent_id": 3, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 5, "parent_id": 2, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, "value": "Promise { }", }, "thread_id": 0, @@ -416,7 +949,7 @@ exports[`mapping mocked http client requests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 4, + "id": 6, "parent_id": 1, "thread_id": 0, }, @@ -429,7 +962,7 @@ exports[`mapping mocked http client requests 1`] = ` }, "url": "http://localhost:27628/endpoint/one", }, - "id": 5, + "id": 7, "thread_id": 0, }, { @@ -439,8 +972,141 @@ exports[`mapping mocked http client requests 1`] = ` "headers": {}, "status_code": 200, }, - "id": 6, - "parent_id": 5, + "id": 8, + "parent_id": 7, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 9, + "lineno": 6, + "method_id": "consume", + "parameters": [ + { + "class": "OverriddenClientRequest", + "name": "request", + "object_id": 4, + "value": " OverriddenClientRequest { + _events: [Object: null prototype] { finish: [Function (anonymous)] }, + _eventsCount: 1, + _maxListeners: undefined, + outputData: [], + outputSize: 0, + writable: true, + destroyed: false, + _last: false, + chunkedEncoding: false, + shouldKeepAlive: true, + maxRequestsOnConnectionReached: false, + _defaultKeepAlive: true, + useChunkedEncodingByDefault: true, + sendDate: false, + _removedConnection: false, + _removedContLen: false, + _removedTE: false, + strictContentLength: false, + _contentLength: null, + _hasBody: true, + _trailer: '', + finished: false, + _headerSent: false, + _closed: false, + socket: Socket { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + bufferSize: 0, + writableLength: 0, + writable: true, + readable: true, + pending: false, + destroyed: false, + connecting: true, + _hadError: false, + timeout: 0, + remoteFamily: 'IPv4', + remoteAddress: '127.0.0.1', + localAddress: '127.0.0.1', + remotePort: 27628, + localPort: 27628, + [Symbol(kCapture)]: false + }, + _header: null, + _keepAliveTimeout: 0, + _onPendingData: [Function: nop], + path: '/endpoint/two?p1=v1&p2=v2', + method: 'POST', + write: [Function (anonymous)], + end: [Function (anonymous)], + flushHeaders: [Function (anonymous)], + req: [Circular *1], + options: { + hostname: 'localhost', + port: 27628, + path: '/endpoint/two?p1=v1&p2=v2', + method: 'POST', + headers: [Object], + proto: 'http', + host: 'localhost:27628' + }, + interceptors: [ [Interceptor], [Interceptor] ], + response: IncomingMessage { + _readableState: [ReadableState], + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + socket: [Socket], + httpVersionMajor: null, + httpVersionMinor: null, + httpVersion: null, + complete: false, + rawHeaders: [], + rawTrailers: [], + joinDuplicateHeaders: false, + aborted: false, + upgrade: null, + url: '', + method: null, + statusCode: null, + statusMessage: null, + client: [Socket], + _consuming: false, + _dumped: false, + [Symbol(kCapture)]: false, + [Symbol(kHeaders)]: null, + [Symbol(kHeadersCount)]: 0, + [Symbol(kTrailers)]: null, + [Symbol(kTrailersCount)]: 0 + }, + requestBodyBuffers: [], + playbackStarted: false, + readyToStartPlaybackOnSocketEvent: false, + [Symbol(kCapture)]: false, + [Symbol(kBytesWritten)]: 0, + [Symbol(kNeedDrain)]: false, + [Symbol(corked)]: 0, + [Symbol(kOutHeaders)]: [Object: null prototype] { 'content-type': [Array] }, + [Symbol(errored)]: null, + [Symbol(kHighWaterMark)]: 16384, + [Symbol(kRejectNonStandardBodyWrites)]: false +}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 10, + "parent_id": 9, + "return_value": { + "class": "Promise", + "object_id": 5, + "value": "Promise { }", + }, "thread_id": 0, }, { @@ -453,7 +1119,7 @@ exports[`mapping mocked http client requests 1`] = ` "request_method": "POST", "url": "http://localhost:27628/endpoint/two", }, - "id": 7, + "id": 11, "thread_id": 0, }, { @@ -463,8 +1129,145 @@ exports[`mapping mocked http client requests 1`] = ` "headers": {}, "status_code": 200, }, - "id": 8, - "parent_id": 7, + "id": 12, + "parent_id": 11, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 13, + "lineno": 6, + "method_id": "consume", + "parameters": [ + { + "class": "OverriddenClientRequest", + "name": "request", + "object_id": 6, + "value": " OverriddenClientRequest { + _events: [Object: null prototype] { finish: [Function (anonymous)] }, + _eventsCount: 1, + _maxListeners: undefined, + outputData: [], + outputSize: 0, + writable: true, + destroyed: false, + _last: false, + chunkedEncoding: false, + shouldKeepAlive: true, + maxRequestsOnConnectionReached: false, + _defaultKeepAlive: true, + useChunkedEncodingByDefault: true, + sendDate: false, + _removedConnection: false, + _removedContLen: false, + _removedTE: false, + strictContentLength: false, + _contentLength: null, + _hasBody: true, + _trailer: '', + finished: true, + _headerSent: false, + _closed: false, + socket: Socket { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + bufferSize: 0, + writableLength: 0, + writable: true, + readable: true, + pending: false, + destroyed: false, + connecting: true, + _hadError: false, + timeout: 0, + remoteFamily: 'IPv4', + remoteAddress: '127.0.0.1', + localAddress: '127.0.0.1', + remotePort: 27628, + localPort: 27628, + [Symbol(kCapture)]: false + }, + _header: null, + _keepAliveTimeout: 0, + _onPendingData: [Function: nop], + path: '/endpoint/three', + method: undefined, + write: [Function (anonymous)], + end: [Function (anonymous)], + flushHeaders: [Function (anonymous)], + req: [Circular *1], + options: { + protocol: 'http:', + hostname: 'localhost', + hash: '', + search: '', + pathname: '/endpoint/three', + path: '/endpoint/three', + href: 'http://localhost:27628/endpoint/three', + port: 27628, + proto: 'http', + host: 'localhost:27628', + headers: {} + }, + interceptors: [ [Interceptor] ], + response: IncomingMessage { + _readableState: [ReadableState], + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + socket: [Socket], + httpVersionMajor: null, + httpVersionMinor: null, + httpVersion: null, + complete: false, + rawHeaders: [], + rawTrailers: [], + joinDuplicateHeaders: false, + aborted: false, + upgrade: null, + url: '', + method: null, + statusCode: null, + statusMessage: null, + client: [Socket], + _consuming: false, + _dumped: false, + [Symbol(kCapture)]: false, + [Symbol(kHeaders)]: null, + [Symbol(kHeadersCount)]: 0, + [Symbol(kTrailers)]: null, + [Symbol(kTrailersCount)]: 0 + }, + requestBodyBuffers: [], + playbackStarted: false, + readyToStartPlaybackOnSocketEvent: false, + [Symbol(kCapture)]: false, + [Symbol(kBytesWritten)]: 0, + [Symbol(kNeedDrain)]: false, + [Symbol(corked)]: 0, + [Symbol(kOutHeaders)]: null, + [Symbol(errored)]: null, + [Symbol(kHighWaterMark)]: 16384, + [Symbol(kRejectNonStandardBodyWrites)]: false +}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 14, + "parent_id": 13, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { }", + }, "thread_id": 0, }, { @@ -475,7 +1278,7 @@ exports[`mapping mocked http client requests 1`] = ` }, "url": "http://localhost:27628/endpoint/three", }, - "id": 9, + "id": 15, "thread_id": 0, }, { @@ -487,8 +1290,8 @@ exports[`mapping mocked http client requests 1`] = ` }, "status_code": 404, }, - "id": 10, - "parent_id": 9, + "id": 16, + "parent_id": 15, "thread_id": 0, }, ], diff --git a/test/__snapshots__/mysql.test.ts.snap b/test/__snapshots__/mysql.test.ts.snap index 62dc86e4..427d2487 100644 --- a/test/__snapshots__/mysql.test.ts.snap +++ b/test/__snapshots__/mysql.test.ts.snap @@ -7,12 +7,24 @@ exports[`mapping MySQL tests 1`] = ` "children": [ { "children": [ + { + "location": "index.js:15", + "name": "newConnection", + "static": true, + "type": "function", + }, { "location": "index.js:17", "name": "main", "static": true, "type": "function", }, + { + "location": "index.js:4", + "name": "promisify", + "static": true, + "type": "function", + }, ], "name": "index", "type": "class", @@ -23,14 +35,50 @@ exports[`mapping MySQL tests 1`] = ` }, ], "eventUpdates": { - "3": { + "13": { "elapsed": 31.337, "event": "return", - "id": 3, + "id": 13, + "parent_id": 11, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "19": { + "elapsed": 31.337, + "event": "return", + "id": 19, + "parent_id": 17, + "return_value": { + "class": "Promise", + "object_id": 11, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "6": { + "elapsed": 31.337, + "event": "return", + "id": 6, + "parent_id": 4, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "7": { + "elapsed": 31.337, + "event": "return", + "id": 7, "parent_id": 1, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, "value": "Promise { undefined }", }, "thread_id": 0, @@ -49,8 +97,172 @@ exports[`mapping MySQL tests 1`] = ` "thread_id": 0, }, { + "defined_class": "index", "event": "call", "id": 2, + "lineno": 15, + "method_id": "newConnection", + "parameters": [], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 3, + "parent_id": 2, + "return_value": { + "class": "Connection", + "object_id": 1, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 4, + "lineno": 4, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: query]", + }, + { + "class": "Connection", + "name": "thisArg", + "object_id": 1, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + { + "class": "String", + "value": ""SELECT 'Connection.query'"", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 5, "sql_query": { "database_type": "mysql", "sql": "SELECT 'Connection.query'", @@ -60,11 +272,23 @@ exports[`mapping MySQL tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 3, + "id": 6, + "parent_id": 4, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 7, "parent_id": 1, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, "value": "Promise { }", }, "thread_id": 0, @@ -76,22 +300,204 @@ exports[`mapping MySQL tests 1`] = ` { "class": "Error", "message": "connect ECONNREFUSED 127.0.0.1:3306", - "object_id": 2, + "object_id": 4, }, ], - "id": 4, - "parent_id": 2, + "id": 8, + "parent_id": 5, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 5, + "id": 9, + "lineno": 15, + "method_id": "newConnection", + "parameters": [], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 10, + "parent_id": 9, + "return_value": { + "class": "Connection", + "object_id": 5, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 11, + "lineno": 4, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: query]", + }, + { + "class": "Connection", + "name": "thisArg", + "object_id": 5, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + { + "class": "String", + "value": ""SELECT 'Connection.query with values', ?, ?"", + }, + { + "class": "Array", + "object_id": 6, + "size": 2, + "value": "[ 1, 'ABC' ]", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 12, "sql_query": { "database_type": "mysql", "sql": "SELECT 'Connection.query with values', ?, ?", }, "thread_id": 0, }, + { + "elapsed": 31.337, + "event": "return", + "id": 13, + "parent_id": 11, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { }", + }, + "thread_id": 0, + }, { "elapsed": 31.337, "event": "return", @@ -99,22 +505,205 @@ exports[`mapping MySQL tests 1`] = ` { "class": "Error", "message": "connect ECONNREFUSED 127.0.0.1:3306", - "object_id": 3, + "object_id": 8, }, ], - "id": 6, - "parent_id": 5, + "id": 14, + "parent_id": 12, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 7, + "id": 15, + "lineno": 15, + "method_id": "newConnection", + "parameters": [], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 16, + "parent_id": 15, + "return_value": { + "class": "Connection", + "object_id": 9, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 17, + "lineno": 4, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: query]", + }, + { + "class": "Connection", + "name": "thisArg", + "object_id": 9, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + { + "class": "Object", + "object_id": 10, + "properties": [ + { + "class": "String", + "name": "sql", + }, + ], + "value": "{ sql: "SELECT 'Connection.query with options'" }", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 18, "sql_query": { "database_type": "mysql", "sql": "SELECT 'Connection.query with options'", }, "thread_id": 0, }, + { + "elapsed": 31.337, + "event": "return", + "id": 19, + "parent_id": 17, + "return_value": { + "class": "Promise", + "object_id": 11, + "value": "Promise { }", + }, + "thread_id": 0, + }, { "elapsed": 31.337, "event": "return", @@ -122,16 +711,96 @@ exports[`mapping MySQL tests 1`] = ` { "class": "Error", "message": "connect ECONNREFUSED 127.0.0.1:3306", - "object_id": 4, + "object_id": 12, }, ], - "id": 8, - "parent_id": 7, + "id": 20, + "parent_id": 18, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 9, + "id": 21, + "lineno": 15, + "method_id": "newConnection", + "parameters": [], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 22, + "parent_id": 21, + "return_value": { + "class": "Connection", + "object_id": 13, + "value": " Connection { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + config: ConnectionConfig { + host: '127.0.0.1', + port: 3306, + localAddress: undefined, + socketPath: undefined, + user: undefined, + password: undefined, + database: undefined, + connectTimeout: 10000, + insecureAuth: false, + supportBigNumbers: false, + bigNumberStrings: false, + dateStrings: false, + debug: undefined, + trace: true, + stringifyObjects: false, + timezone: 'local', + flags: '', + queryFormat: undefined, + pool: undefined, + ssl: false, + localInfile: true, + multipleStatements: false, + typeCast: true, + maxPacketSize: 0, + charsetNumber: 33, + clientFlags: 455631 + }, + _socket: undefined, + _protocol: Protocol { + _events: [Object: null prototype] {}, + _eventsCount: 0, + _maxListeners: undefined, + readable: true, + writable: true, + _config: [ConnectionConfig], + _connection: [Circular *1], + _callback: null, + _fatalError: null, + _quitSequence: null, + _handshake: false, + _handshaked: false, + _ended: false, + _destroyed: false, + _queue: [], + _handshakeInitializationPacket: null, + _parser: [Parser], + [Symbol(kCapture)]: false + }, + _connectCalled: false, + state: 'disconnected', + threadId: null, + [Symbol(kCapture)]: false +}", + }, + "thread_id": 0, + }, + { + "event": "call", + "id": 23, "sql_query": { "database_type": "mysql", "sql": "SELECT 'Connection.query without a callback", @@ -145,11 +814,11 @@ exports[`mapping MySQL tests 1`] = ` { "class": "Error", "message": "connect ECONNREFUSED 127.0.0.1:3306", - "object_id": 5, + "object_id": 14, }, ], - "id": 10, - "parent_id": 9, + "id": 24, + "parent_id": 23, "thread_id": 0, }, ], diff --git a/test/__snapshots__/sqlite.test.ts.snap b/test/__snapshots__/sqlite.test.ts.snap index 0f083cb0..d822c078 100644 --- a/test/__snapshots__/sqlite.test.ts.snap +++ b/test/__snapshots__/sqlite.test.ts.snap @@ -13,6 +13,12 @@ exports[`mapping Sqlite tests 1`] = ` "static": true, "type": "function", }, + { + "location": "index.js:5", + "name": "promisify", + "static": true, + "type": "function", + }, ], "name": "index", "type": "class", @@ -23,18 +29,186 @@ exports[`mapping Sqlite tests 1`] = ` }, ], "eventUpdates": { - "3": { + "13": { "elapsed": 31.337, "event": "return", - "id": 3, + "id": 13, + "parent_id": 11, + "return_value": { + "class": "Promise", + "object_id": 5, + "value": "Promise { { "'Database.get'": 'Database.get' } }", + }, + "thread_id": 0, + }, + "17": { + "elapsed": 31.337, + "event": "return", + "id": 17, + "parent_id": 15, + "return_value": { + "class": "Promise", + "object_id": 6, + "value": "Promise { { "'Database.each'": 'Database.each' } }", + }, + "thread_id": 0, + }, + "21": { + "elapsed": 31.337, + "event": "return", + "id": 21, + "parent_id": 19, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "25": { + "elapsed": 31.337, + "event": "return", + "id": 25, + "parent_id": 23, + "return_value": { + "class": "Promise", + "object_id": 8, + "value": "Promise { 1 }", + }, + "thread_id": 0, + }, + "29": { + "elapsed": 31.337, + "event": "return", + "id": 29, + "parent_id": 27, + "return_value": { + "class": "Promise", + "object_id": 9, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "33": { + "elapsed": 31.337, + "event": "return", + "id": 33, + "parent_id": 31, + "return_value": { + "class": "Promise", + "object_id": 11, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "37": { + "elapsed": 31.337, + "event": "return", + "id": 37, + "parent_id": 35, + "return_value": { + "class": "Promise", + "object_id": 13, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "4": { + "elapsed": 31.337, + "event": "return", + "id": 4, + "parent_id": 2, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "41": { + "elapsed": 31.337, + "event": "return", + "id": 41, + "parent_id": 39, + "return_value": { + "class": "Promise", + "object_id": 15, + "value": "Promise { [ [Object] ] }", + }, + "thread_id": 0, + }, + "45": { + "elapsed": 31.337, + "event": "return", + "id": 45, + "parent_id": 43, + "return_value": { + "class": "Promise", + "object_id": 17, + "value": "Promise { { "'Statement.get'": 'Statement.get' } }", + }, + "thread_id": 0, + }, + "49": { + "elapsed": 31.337, + "event": "return", + "id": 49, + "parent_id": 47, + "return_value": { + "class": "Promise", + "object_id": 19, + "value": "Promise { { "'Statement.each'": 'Statement.each' } }", + }, + "thread_id": 0, + }, + "5": { + "elapsed": 31.337, + "event": "return", + "id": 5, "parent_id": 1, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 3, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "53": { + "elapsed": 31.337, + "event": "return", + "id": 53, + "parent_id": 51, + "return_value": { + "class": "Promise", + "object_id": 21, + "value": "Promise { undefined }", + }, + "thread_id": 0, + }, + "57": { + "elapsed": 31.337, + "event": "return", + "id": 57, + "parent_id": 55, + "return_value": { + "class": "Promise", + "object_id": 22, "value": "Promise { undefined }", }, "thread_id": 0, }, + "9": { + "elapsed": 31.337, + "event": "return", + "id": 9, + "parent_id": 7, + "return_value": { + "class": "Promise", + "object_id": 4, + "value": "Promise { [ [Object] ] }", + }, + "thread_id": 0, + }, }, "events": [ { @@ -48,23 +222,341 @@ exports[`mapping Sqlite tests 1`] = ` "static": true, "thread_id": 0, }, + { + "defined_class": "index", + "event": "call", + "id": 2, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.run'"", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 3, + "sql_query": { + "database_type": "sqlite", + "sql": "SELECT 'Database.run'", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 4, + "parent_id": 2, + "return_value": { + "class": "Promise", + "object_id": 2, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 5, + "parent_id": 1, + "return_value": { + "class": "Promise", + "object_id": 3, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 6, + "parent_id": 3, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 7, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.all'"", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 8, + "sql_query": { + "database_type": "sqlite", + "sql": "SELECT 'Database.all'", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 9, + "parent_id": 7, + "return_value": { + "class": "Promise", + "object_id": 4, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 10, + "parent_id": 8, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 11, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.get'"", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 12, + "sql_query": { + "database_type": "sqlite", + "sql": "SELECT 'Database.get'", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 13, + "parent_id": 11, + "return_value": { + "class": "Promise", + "object_id": 5, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 14, + "parent_id": 12, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 15, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.each'"", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 16, + "sql_query": { + "database_type": "sqlite", + "sql": "SELECT 'Database.each'", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 17, + "parent_id": 15, + "return_value": { + "class": "Promise", + "object_id": 6, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 18, + "parent_id": 16, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 19, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: exec]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.exec'"", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 20, + "sql_query": { + "database_type": "sqlite", + "sql": "SELECT 'Database.exec'", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 21, + "parent_id": 19, + "return_value": { + "class": "Promise", + "object_id": 7, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 22, + "parent_id": 20, + "thread_id": 0, + }, + { + "defined_class": "index", + "event": "call", + "id": 23, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.each with row callback'"", + }, + { + "class": "Function", + "value": "[Function (anonymous)]", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, { "event": "call", - "id": 2, + "id": 24, "sql_query": { "database_type": "sqlite", - "sql": "SELECT 'Database.run'", + "sql": "SELECT 'Database.each with row callback'", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 3, - "parent_id": 1, + "id": 25, + "parent_id": 23, "return_value": { "class": "Promise", - "object_id": 1, + "object_id": 8, "value": "Promise { }", }, "thread_id": 0, @@ -72,173 +564,322 @@ exports[`mapping Sqlite tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 4, - "parent_id": 2, + "id": 26, + "parent_id": 24, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 5, + "id": 27, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.run with params', ? AS a, ? AS b"", + }, + { + "class": "Number", + "value": "1", + }, + { + "class": "Number", + "value": "2", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 28, "sql_query": { "database_type": "sqlite", - "sql": "SELECT 'Database.all'", + "sql": "SELECT 'Database.run with params', ? AS a, ? AS b", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 6, - "parent_id": 5, - "thread_id": 0, - }, - { - "event": "call", - "id": 7, - "sql_query": { - "database_type": "sqlite", - "sql": "SELECT 'Database.get'", + "id": 29, + "parent_id": 27, + "return_value": { + "class": "Promise", + "object_id": 9, + "value": "Promise { }", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 8, - "parent_id": 7, + "id": 30, + "parent_id": 28, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 9, + "id": 31, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function (anonymous)]", + }, + { + "class": "Database", + "name": "thisArg", + "object_id": 1, + "value": "Database {}", + }, + { + "class": "String", + "value": ""SELECT 'Database.run with object param', $foo, $bar"", + }, + { + "class": "Object", + "object_id": 10, + "properties": [ + { + "class": "Number", + "name": "$foo", + }, + { + "class": "String", + "name": "$bar", + }, + ], + "value": "{ '$foo': 123, '$bar': 'abc' }", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 32, "sql_query": { "database_type": "sqlite", - "sql": "SELECT 'Database.each'", + "sql": "SELECT 'Database.run with object param', $foo, $bar", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 10, - "parent_id": 9, - "thread_id": 0, - }, - { - "event": "call", - "id": 11, - "sql_query": { - "database_type": "sqlite", - "sql": "SELECT 'Database.exec'", + "id": 33, + "parent_id": 31, + "return_value": { + "class": "Promise", + "object_id": 11, + "value": "Promise { }", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 12, - "parent_id": 11, + "id": 34, + "parent_id": 32, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 13, + "id": 35, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: run]", + }, + { + "class": "Statement", + "name": "thisArg", + "object_id": 12, + "value": "Statement {}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 36, "sql_query": { "database_type": "sqlite", - "sql": "SELECT 'Database.each with row callback'", + "sql": "SELECT 'Statement.run'", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 14, - "parent_id": 13, - "thread_id": 0, - }, - { - "event": "call", - "id": 15, - "sql_query": { - "database_type": "sqlite", - "sql": "SELECT 'Database.run with params', ? AS a, ? AS b", + "id": 37, + "parent_id": 35, + "return_value": { + "class": "Promise", + "object_id": 13, + "value": "Promise { }", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 16, - "parent_id": 15, + "id": 38, + "parent_id": 36, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 17, + "id": 39, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: all]", + }, + { + "class": "Statement", + "name": "thisArg", + "object_id": 14, + "value": "Statement {}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 40, "sql_query": { "database_type": "sqlite", - "sql": "SELECT 'Database.run with object param', $foo, $bar", + "sql": "SELECT 'Statement.all'", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 18, - "parent_id": 17, - "thread_id": 0, - }, - { - "event": "call", - "id": 19, - "sql_query": { - "database_type": "sqlite", - "sql": "SELECT 'Statement.run'", + "id": 41, + "parent_id": 39, + "return_value": { + "class": "Promise", + "object_id": 15, + "value": "Promise { }", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 20, - "parent_id": 19, + "id": 42, + "parent_id": 40, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 21, + "id": 43, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: get]", + }, + { + "class": "Statement", + "name": "thisArg", + "object_id": 16, + "value": "Statement {}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 44, "sql_query": { "database_type": "sqlite", - "sql": "SELECT 'Statement.all'", + "sql": "SELECT 'Statement.get'", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 22, - "parent_id": 21, - "thread_id": 0, - }, - { - "event": "call", - "id": 23, - "sql_query": { - "database_type": "sqlite", - "sql": "SELECT 'Statement.get'", + "id": 45, + "parent_id": 43, + "return_value": { + "class": "Promise", + "object_id": 17, + "value": "Promise { }", }, "thread_id": 0, }, { "elapsed": 31.337, "event": "return", - "id": 24, - "parent_id": 23, + "id": 46, + "parent_id": 44, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 25, + "id": 47, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: each]", + }, + { + "class": "Statement", + "name": "thisArg", + "object_id": 18, + "value": "Statement {}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 48, "sql_query": { "database_type": "sqlite", "sql": "SELECT 'Statement.each'", @@ -248,13 +889,48 @@ exports[`mapping Sqlite tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 26, - "parent_id": 25, + "id": 49, + "parent_id": 47, + "return_value": { + "class": "Promise", + "object_id": 19, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 50, + "parent_id": 48, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 27, + "id": 51, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: run]", + }, + { + "class": "Statement", + "name": "thisArg", + "object_id": 20, + "value": "Statement {}", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 52, "sql_query": { "database_type": "sqlite", "sql": "SELECT 'Statement.run - prepare once run twice'", @@ -264,13 +940,48 @@ exports[`mapping Sqlite tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 28, - "parent_id": 27, + "id": 53, + "parent_id": 51, + "return_value": { + "class": "Promise", + "object_id": 21, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 54, + "parent_id": 52, "thread_id": 0, }, { + "defined_class": "index", "event": "call", - "id": 29, + "id": 55, + "lineno": 5, + "method_id": "promisify", + "parameters": [ + { + "class": "Function", + "name": "method", + "value": "[Function: run]", + }, + { + "class": "Statement", + "name": "thisArg", + "object_id": 20, + "value": "Statement { lastID: 0, changes: 0 }", + }, + ], + "path": "index.js", + "static": true, + "thread_id": 0, + }, + { + "event": "call", + "id": 56, "sql_query": { "database_type": "sqlite", "sql": "SELECT 'Statement.run - prepare once run twice'", @@ -280,13 +991,25 @@ exports[`mapping Sqlite tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 30, - "parent_id": 29, + "id": 57, + "parent_id": 55, + "return_value": { + "class": "Promise", + "object_id": 22, + "value": "Promise { }", + }, + "thread_id": 0, + }, + { + "elapsed": 31.337, + "event": "return", + "id": 58, + "parent_id": 56, "thread_id": 0, }, { "event": "call", - "id": 31, + "id": 59, "sql_query": { "database_type": "sqlite", "sql": "SELECT 'Database.run without a completion callback'", @@ -296,13 +1019,13 @@ exports[`mapping Sqlite tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 32, - "parent_id": 31, + "id": 60, + "parent_id": 59, "thread_id": 0, }, { "event": "call", - "id": 33, + "id": 61, "sql_query": { "database_type": "sqlite", "sql": "SELECT 'Statement.run without a completion callback'", @@ -312,8 +1035,8 @@ exports[`mapping Sqlite tests 1`] = ` { "elapsed": 31.337, "event": "return", - "id": 34, - "parent_id": 33, + "id": 62, + "parent_id": 61, "thread_id": 0, }, ],