Open tcort opened 6 years ago
Hey @tcort Apologies I missed this - FreeBSD 10.3 Doesn't have dtrace enabled by default - It is in 11.0 or above versions The clue is in
Oddly, if I've run dtrace since the last boot, I don't get the error.
You can load dtrace by running kldload dtraceall
If you want that to persist beyond reboots you need edit /boot/loader.conf
or /boot/loader.local.conf
add the line dtraceall_load="YES"
@No9 it also happens on an up-to-date FreeBSD:
% uname -a
FreeBSD lapo.andxor.it 11.1-RELEASE-p10 FreeBSD 11.1-RELEASE-p10 #0: Tue May 8 05:21:56 UTC 2018 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
% cat testDTrace.js
var dtrace = require('dtrace-provider');
PROVIDER = dtrace.createDTraceProvider('restify');
PROVIDER.addProbe('route-start', 'char *', 'char *', 'int', 'char *', 'char *', 'json');
PROVIDER.enable();
% node testDTrace
/home/lapo/svn/nodejs/axosms/trunk/testDTrace.js:4
PROVIDER.enable();
^
Error: failed to load DOF: No such file or directory
at Object.<anonymous> (/home/lapo/test/testDTrace.js:4:10)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
(I was trying to debug the error in have in restify
so I extracted a minimal test case from its usage)
restify
use-case does wrap the constructor in try/catch
to ignore DTrace on system that don't use it, but unfortunately the enable()
is outside of the try
.
When DTrace is not available, do you think the constructor should trow (and thus restify
usage is already ok) or is it expected that only enable()
can fail? (in this case I will suggest or PR them to wrap everything inside the try
)
I noticed that other modules, e.g. bunyan
, use this with no try/catch
; it might be worth supporting "FreeBSD with no dtrace module loaded in the kernel" as an unsupported platform and automatically using «a stub no-op implementation provided for compatibility» (as stated in the README).
Hi @lapo-luchini
automatically using «a stub no-op implementation provided for compatibility»
I'm not 100% that covers all the scenarios i.e. if you have a system that has successfully built the provider you would expect a failure if dtrace wasn't enabled not silently swallow it
Maybe the answer is to warn during the build or when the the module is loaded?
True that. Some more whild ideas:
require
: this would fix both restify
and bunyan
(with no change at all on their part) but could well break others that expected maybe a failure on new
instead of require
require('dtrace-provider').optional=true
to be used before recursive require
s (this would allow the most external user change but little control in inner modules)enable
, stating it clearly in docs and opening PRs on all dependencies to check for that
Symptoms
I'm using node v8.10.0 built from source on FreeBSD/amd64 10.3 (built with clang and clang++, no configure flags given). I tried
dtrace-provider
(just the simple code snippet from the README) and it results in an error:Error: failed to load DOF: No such file or directory
.Version Numbers:
Steps to reproduce:
Clone the repo...
Install and Build
Make a little demo based on the example in
README.md
Run it...
Oddly, if I've run dtrace since the last boot, I don't get the error.
Build Log