Using elastic-apm-node with Angular Universal SSR


(Peter Bouda) #1

I am using elastic-apm-node in a Loopback application (so Express-based), which actually does server-side rendering of an Angular application via Angular Universal. The setup is not straight-forward, so I cannot provide a simple sample project atm, but I hope the problem is more general and others experience the same problem... Angular Universal wraps everything in zone.js and my guess is that this interferes with the async wrapper of elastic-apm-node. I can start the Loopback app but then all requests return a 404 error (I attach a log below) and nothing is sent to APM. When I turn on debugging of elastic-apm-node the last message after start is:

Elastic APM caught unhandled exception: macroTask 'setTimeout': can not transition to 'running', expecting state 'scheduled', was 'notScheduled'.

Does anyone experience a similar problem? Might there be some kind of workaround?

Here is the full error after a request:

Error: Cannot GET /
    at raiseUrlNotFoundError (\Projects\dissemination\node_modules\loopback\server\middleware\url-not-found.js:21:17)
    at \Projects\dissemination\node_modules\elastic-apm-node\lib\instrumentation\modules\express.js:56:25
    at Layer.handle [as handle_request] (\Projects\dissemination\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (\Projects\dissemination\node_modules\express\lib\router\index.js:317:13)
    at \Projects\dissemination\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (\Projects\dissemination\node_modules\express\lib\router\index.js:335:12)
    at next (\Projects\dissemination\node_modules\express\lib\router\index.js:275:10)
    at urlencodedParser (\Projects\dissemination\node_modules\body-parser\lib\types\urlencoded.js:91:7)
    at \Projects\dissemination\node_modules\elastic-apm-node\lib\instrumentation\modules\express.js:56:25
    at Layer.handle [as handle_request] (\Projects\dissemination\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (\Projects\dissemination\node_modules\express\lib\router\index.js:317:13)
    at \Projects\dissemination\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (\Projects\dissemination\node_modules\express\lib\router\index.js:335:12)
    at next (\Projects\dissemination\node_modules\express\lib\router\index.js:275:10)
    at jsonParser (\Projects\dissemination\node_modules\body-parser\lib\types\json.js:110:7)
    at \Projects\dissemination\node_modules\elastic-apm-node\lib\instrumentation\modules\express.js:56:25
    at Layer.handle [as handle_request] (\Projects\dissemination\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (\Projects\dissemination\node_modules\express\lib\router\index.js:317:13)
    at \Projects\dissemination\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (\Projects\dissemination\node_modules\express\lib\router\index.js:335:12)
    at next (\Projects\dissemination\node_modules\express\lib\router\index.js:275:10)
    at rewriteUserLiteral (\Projects\dissemination\node_modules\loopback\server\middleware\token.js:26:35)
    at \Projects\dissemination\node_modules\loopback\server\middleware\token.js:148:7
    at ZoneDelegate.invokeTask (\Projects\dissemination\node_modules\zone.js\dist\zone-node.js:421:31)
    at Zone.runTask (\Projects\dissemination\node_modules\zone.js\dist\zone-node.js:188:47)
    at ZoneTask.invokeTask (\Projects\dissemination\node_modules\zone.js\dist\zone-node.js:496:34)
    at ZoneTask.invoke (\Projects\dissemination\node_modules\zone.js\dist\zone-node.js:485:48)
    at data.args.(anonymous function) (\Projects\dissemination\node_modules\zone.js\dist\zone-node.js:1338:25)
    at process._tickCallback (internal/process/next_tick.js:61:11)

Kibana version:
6.6.2

Elasticsearch version:
6.6.2

APM Server version:
6.6.2

APM Agent language and version:
elastic-apm-node 2.6.0


(system) closed #2

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.