I run the same function ts-node and from jest and when It runs through jest you can see that it doesn't work. See ddtrace-problem.zip project example.
vscode
windows
Node version: 12.14.1
Tracer version: 0.17.1
Agent version: Not relevant.
Hi!
I have the same problem running tests with jest and ts-node. I don't know if it is linked to @mkaufma issue, but Node is throwing an error:
node[3057]: ../src/node_file.cc:1336:void node::fs::RealPath(const FunctionCallbackInfo<v8::Value> &): Assertion `(argc) >= (3)' failed.
1: 0x10007f4b9 node::Abort() [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
2: 0x10007f261 node::AppendExceptionLine(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Message>, node::ErrorHandlingMode) [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
3: 0x10008cc8c node::fs::RealPath(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
4: 0x1001e1d40 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
5: 0x1001e131f v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
6: 0x1001e0a20 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
7: 0x100931499 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/******/.nvm/versions/node/v12.15.0/bin/node]
Abort trap: 6
Node version (nvm): 12.15.0
NVM version: 0.33.0
Jest version: 25.1.0
ts-node version: 8.6.2
dd-trace version: 0.18.1 (same problem with v0.17.1, but it works with v0.16.3)
Hello, we're experiencing this as well on the latest plugin's version. :(
ts-jest: 25.2.1
dd-trace: 0.19
jest: 25.1
node: 12.14.1
We also observed this during jest tests, when run:
[email protected] 10.13 (as well as various 12.x versions).circleci/classic:edge image.datadogTracer.wrap, but we do use datadogTracer.trace.ts-jest; we compile with tsc and then run jest against .js tests.This makes the crash go away for us:
datadogTracer.use('fs', false);
We also observed this during jest tests, when run:
- using on
[email protected]- node
10.13(as well as various12.xversions).- I cannot reproduce this locally, but reproduces every time when I run our jest suite in circleci. We use their
circleci/classic:edgeimage.- we're not (directly) using
datadogTracer.wrap, but we do usedatadogTracer.trace.- we're _not_ using
ts-jest; we compile with tsc and then run jest against .js tests.This makes the crash go away for us:
datadogTracer.use('fs', false);
Tried your workaround but it doesn't seem to be working 100% of the time - it's quite flaky, unfortunately.
fyi @bengl
Upgrading to jest 25.x seemed to solve the issue for me (perhaps its patching fs itself better?) with dd-trace 0.20.3
Closing since the issue seems to be resolved and the tracer should generally be mocked when using Jest. Please reopen if you are still having the issue.
Most helpful comment
We also observed this during jest tests, when run:
[email protected]10.13(as well as various12.xversions).circleci/classic:edgeimage.datadogTracer.wrap, but we do usedatadogTracer.trace.ts-jest; we compile with tsc and then run jest against .js tests.This makes the crash go away for us: