getappmap / appmap-agent-js

This project is deprecated. Please use https://github.com/getappmap/appmap-node/ to record Node.js applications.
Other
28 stars 8 forks source link

Out of memory recording `@appland/scanner` #112

Closed dustinbyrne closed 2 years ago

dustinbyrne commented 2 years ago

I'm trying to get a recording of the @appland/scanner CLI. The process crashes is panicking due to OOM. From my observations, my best guess is that it's running out of memory during the initialization process. Without the agent the command I'm trying to record exits almost immediately, so I can't imagine it's due to the size of the recording itself.

$ npx @appland/appmap-agent-js --recorder=process -- node built/cli.js scan --watch
(node:30139) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

<--- Last few GCs --->

[30110:0x66b2900]    77269 ms: Scavenge 4062.2 (4136.3) -> 4060.0 (4137.5) MB, 7.2 / 0.0 ms  (average mu = 0.527, current mu = 0.512) allocation failure 
[30110:0x66b2900]    77282 ms: Scavenge 4063.4 (4137.5) -> 4061.2 (4138.8) MB, 7.0 / 0.0 ms  (average mu = 0.527, current mu = 0.512) allocation failure 
[30110:0x66b2900]    78252 ms: Scavenge 4064.6 (4138.8) -> 4062.3 (4147.3) MB, 964.4 / 0.0 ms  (average mu = 0.527, current mu = 0.512) allocation failure 

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb09c10 node::Abort() [node]
 2: 0xa1c193 node::FatalError(char const*, char const*) [node]
 3: 0xcf8dbe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xcf9137 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xeb09d5  [node]
 6: 0xec069d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 7: 0xec339e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0xe848da v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
 9: 0x11fd626 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
10: 0x15f2099  [node]
Aborted
Error: ERRNO 32: Broken pipe
    at write (/home/db/dev/applandinc/appmap-js/node_modules/posix-socket-messaging/lib/index.js:20:19)
    at exports.send (/home/db/dev/applandinc/appmap-js/node_modules/posix-socket-messaging/lib/index.js:38:3)
    at sendEmitter (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/emitter/remote-socket/index.mjs:39:9)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:7
    at AsyncHook.after (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-group/node/index.mjs:67:30)
    at emitHook (node:internal/async_hooks:233:38)
    at promiseAfterHook (node:internal/async_hooks:350:5)
/home/db/dev/applandinc/appmap-js/node_modules/posix-socket-messaging/lib/index.js:20       
  if (PosixSocket.send(sockfd, arraybuffer, length, 0) < length) {
                  ^

Error: ERRNO 32: Broken pipe
    at write (/home/db/dev/applandinc/appmap-js/node_modules/posix-socket-messaging/lib/index.js:20:19)
    at exports.send (/home/db/dev/applandinc/appmap-js/node_modules/posix-socket-messaging/lib/index.js:38:3)
    at sendEmitter (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/emitter/remote-socket/index.mjs:39:9)
    at stopTrack (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:84:7)
    at process.<anonymous> (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/recorder-cli/default/index.mjs:60:13)
    at process.emit (node:events:539:35)
    at process.exit (node:internal/process/per_thread:189:15)
    at fatalError (node:internal/async_hooks:174:11)
    at emitHook (node:internal/async_hooks:237:5)
    at promiseAfterHook (node:internal/async_hooks:350:5) {
  errno: 32,
  code: 'Broken pipe'
}

My appmap.yml:

name: scanner
packages:
  - path: built/cli/scan

I tried interrupting the agent while it was in the process of consuming memory to see where it was occurring, but this would crash the agent:

$ npx @appland/appmap-agent-js --recorder=process -- node built/cli.js scan --watch
Debugger attached.
Debugger attached.
Debugger attached.
(node:31348) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:174
      (getPrototypeOf(object) === null ||
       ^

RangeError: Maximum call stack size exceeded
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:174:8)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
    at serialize (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:252:24)
    at serializeBeforeApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:33:11)
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/recording.mjs:26:9
    at file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:39:28
    at runtime.recordBeginApply (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:42:9)
    at get (/home/db/dev/applandinc/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:66)
    at toEntriesSafe (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:30:14)
    at getSpecific (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:177:23)
    at serializeNonEmpty (file:///home/db/dev/applandinc/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:218:19)
FATAL ERROR: 
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 0xb09c10 node::Abort() [node]
 2: 0xa1c193 node::FatalError(char const*, char const*) [node]
 3: 0xa1c19c  [node]
 4: 0xc14118  [node]
 5: 0xc1777e node::inspector::NodeInspectorClient::maxAsyncCallStackDepthChanged(int) [node]
 6: 0x12a59c4 v8_inspector::V8Debugger::setAsyncCallStackDepth(v8_inspector::V8DebuggerAgentImpl*, int) [node]
 7: 0x12a877d v8_inspector::V8DebuggerAgentImpl::setAsyncCallStackDepth(int) [node]
 8: 0x1525d72 v8_inspector::protocol::Debugger::DomainDispatcherImpl::setAsyncCallStackDepth(v8_crdtp::Dispatchable const&) [node]
 9: 0x12ff76b v8_crdtp::UberDispatcher::DispatchResult::Run() [node]
10: 0x12c7b90 v8_inspector::V8InspectorSessionImpl::dispatchProtocolMessage(v8_inspector::StringView) [node]
11: 0xc0e1c1  [node]
12: 0xc31499  [node]
13: 0xc2f94e  [node]
14: 0xc2fc9e  [node]
15: 0xc300ba  [node]
16: 0xa8a538 node::Environment::RunAndClearInterrupts() [node]
17: 0xa8a5a7  [node]
18: 0xe390fa v8::internal::Isolate::InvokeApiInterruptCallbacks() [node]
19: 0xe508c1 v8::internal::StackGuard::HandleInterrupts() [node]
20: 0x11fcd75 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [node]
21: 0x15f2099  [node]
Aborted
Waiting for the debugger to disconnect...
lachrist commented 2 years ago

For the first issue, it might be because of C++ binding of https://github.com/lachrist/posix-socket. Could you try with socket: net in appmap.yml instead?

For the second issue, I think the infinite recursion happens because of async_hooks. You can turn them off with ordering: chronological in appmap.yml.

After I merge the nextjs branch, I can try to replicate these myself.

lachrist commented 2 years ago

@dustinbyrne First of all, do you mean that node built/cli.js scan --watch exits immediately on its own or do you have to kill it first? Because I have to ctrl-c it.

Here are my findings.

I recorded the command and killed it like after 1min. Then, I have an invalid string length error when trying to JSON.stringify the trace. I'm thinking that it is too big to be handled by JSON?

I tried to kill it sooner like after 10s. An appmap gets generated. But it is 50MB and makes the viewer very slow. There are only a bunch of functions that have been recorded. And function-53::desc::get#() at built/cli/scan/watchScan.js:6 gets called 61256 times >_<.

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

I logged the callstack at that function:

YO Error: BOUM
    at Object.get [as FSWatcher] (/Users/soft/Desktop/workspace/appmap-js/packages/scanner/built/cli/scan/watchScan.js:18:35)
    at entries (<anonymous>)
    at toEntriesSafe (file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:31:14)
    at getSpecific (file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:186:23)
    at serializeNonEmpty (file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:229:19)
    at serialize (file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/serialization/default/index.mjs:263:24)
    at formatApplyPayload (file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/frontend/default/payload.mjs:25:13)
    at file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/agent/default/index.mjs:43:7
    at Object.runtime.recordApply (file:///Users/soft/Desktop/workspace/appmap-js/node_modules/@appland/appmap-agent-js/components/hook-apply/default/index.mjs:61:13)
    at Object.get [as FSWatcher] (/Users/soft/Desktop/workspace/appmap-js/packages/scanner/built/cli/scan/watchScan.js:15:28)

So acquiring the property of this object triggered the getter which gets recorded. This is done to populate the properties field of the parameter object format. This can be toggled off with:

serialization:
  impure-hash-inspection: false

Other serialization options here.

Now, the appmap recorded more functions and has a normal size:

Screenshot 2022-09-12 at 12 42 29

anonymous.appmap.json.zip

lachrist commented 2 years ago

TLDR: unsafe object inspection for serialization was at the origin of the error. It can be toggled off with config.serialization["impure-hash-inspection"] = false.

I knew that unsafe serialization would be a problem at some point. But some information required by the appmap spec are best retrieved using unsafe methods. I could try to render some serialization operations less invasive but I'm sure it is impossible to provide the level of detail required by the spec with only safe operations. Should we consider to toggle off unsafe serialization by default?

lachrist commented 2 years ago

@dustinbyrne fixed by 7a23367254de55a8c4d2e1d0a1eef28e247c55bc

anonymous.appmap.json 2.zip

lachrist commented 2 years ago

fix https://github.com/applandinc/appmap-agent-js/pull/117