You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
When attempting to load the New Relic Agent (v9.7.3) using the ESM module loader described here, the automatic instrumentation for Koa fails with the following error:
{"v":0,"level":40,"name":"newrelic","hostname":"0bfcea2519cb","pid":82743,"time":"2022-12-14T21:10:08.234Z","msg":"Custom instrumentation for koa failed. Please report this to the maintainers of the custom instrumentation.","component":"shimmer","stack":"TypeError: Cannot convert undefined or null to object\n at Function.keys (<anonymous>)\n at Object.initialize [as onRequire] (/my-system/node_modules/@newrelic/koa/lib/instrumentation.js:10:31)\n at instrumentPostLoad (/my-system/node_modules/newrelic/lib/shimmer.js:534:25)\n at _postLoad (/my-system/node_modules/newrelic/lib/shimmer.js:591:12)\n at Object.instrumentPostLoad (/my-system/node_modules/newrelic/lib/shimmer.js:477:20)\n at wrapModule (file:///my-system/node_modules/newrelic/lib/esm-shim.mjs:35:18)\n at file:///my-system/node_modules/koa/dist/koa.mjs?hasNrInstrumentation=true:4:28\n at ModuleJob.run (node:internal/modules/esm/module_job:193:25)\n at async Promise.all (index 0)\n at async ESMLoader.import (node:internal/modules/esm/loader:526:24)","message":"Cannot convert undefined or null to object"}
The root cause is at line 10 of instrumentation.js if (!shim || !Koa || Object.keys(Koa.prototype).length > 1) {
When loaded via the ESM module loader, `Koa.prototype' is undefined.
I was able to fix it by simply adding the following line before the if statement above: Koa.prototype = Koa.default.prototype;
The 'Koa.default' export was added for this purpose in the Koa project. See:
Description
When attempting to load the New Relic Agent (v9.7.3) using the ESM module loader described here, the automatic instrumentation for Koa fails with the following error:
{"v":0,"level":40,"name":"newrelic","hostname":"0bfcea2519cb","pid":82743,"time":"2022-12-14T21:10:08.234Z","msg":"Custom instrumentation for koa failed. Please report this to the maintainers of the custom instrumentation.","component":"shimmer","stack":"TypeError: Cannot convert undefined or null to object\n at Function.keys (<anonymous>)\n at Object.initialize [as onRequire] (/my-system/node_modules/@newrelic/koa/lib/instrumentation.js:10:31)\n at instrumentPostLoad (/my-system/node_modules/newrelic/lib/shimmer.js:534:25)\n at _postLoad (/my-system/node_modules/newrelic/lib/shimmer.js:591:12)\n at Object.instrumentPostLoad (/my-system/node_modules/newrelic/lib/shimmer.js:477:20)\n at wrapModule (file:///my-system/node_modules/newrelic/lib/esm-shim.mjs:35:18)\n at file:///my-system/node_modules/koa/dist/koa.mjs?hasNrInstrumentation=true:4:28\n at ModuleJob.run (node:internal/modules/esm/module_job:193:25)\n at async Promise.all (index 0)\n at async ESMLoader.import (node:internal/modules/esm/loader:526:24)","message":"Cannot convert undefined or null to object"}
The root cause is at line 10 of
instrumentation.js
if (!shim || !Koa || Object.keys(Koa.prototype).length > 1) {
When loaded via the ESM module loader, `Koa.prototype' is undefined.
I was able to fix it by simply adding the following line before the
if
statement above:Koa.prototype = Koa.default.prototype;
The 'Koa.default' export was added for this purpose in the Koa project. See:
Steps to Reproduce
Run the New Relic agent in a Koa project following the instructions for using the ESM module loader, and look at the agent logs to find the error above.
The text was updated successfully, but these errors were encountered: