Opened 8 years ago

Closed 8 years ago

#14540 closed defect (fixed)

node.js detection broken on Linux

Reported by: MaxMotovilov Owned by: Rawld Gill
Priority: blocker Milestone: 1.7.3
Component: Loader Version: 1.7.1
Keywords: node.js backport Cc:
Blocked By: Blocking:

Description

https://github.com/dojo/dojo/commit/2abfde8208260b838fcf63844a9a276c251c3ca1

Some improvement... typical installation (nodejs deb package on Ubuntu in my case) results in

process.exePath=='/usr/bin/nodejs'

and the current detection regex misses that. Rolling this commit back should do the trick

Change History (11)

comment:1 Changed 8 years ago by bill

The problem is that the executable is called nodejs instead of node?

comment:2 Changed 8 years ago by Eugene Lazutkin

The problem is the code tries to detect the name of a process, which is brittle, and error-prone (see navigator.userAgent and associated problems). It is much safer to detect an environment, or prominent features, instead of superficial features like OS-dependent process information.

Some detection variants are listed on SO: http://stackoverflow.com/questions/4224606/how-to-check-whether-a-script-is-running-under-node-js

Last edited 8 years ago by Eugene Lazutkin (previous) (diff)

comment:3 Changed 8 years ago by Rawld Gill

Resolution: fixed
Status: newclosed

In [27537]:

improved node detection; fixes #14540; !strict

comment:4 Changed 8 years ago by Rawld Gill

In [27538]:

fixed typo; fixes #14540; !strict

comment:5 Changed 8 years ago by Rawld Gill

In [27539]:

improved node.js detection to prefer user config (if available); refs #14540; !strict

comment:6 Changed 8 years ago by Rawld Gill

Thanks for attending to this Eugene!

I improved the sniff so that I can't see how looking at the executable is still necessary; also allow explicit user override.

Here is an example node.js program that uses the override

global.dojoConfig = {
  has:{
    "host-node":1
  }
};
require("path/to/dojo.js");

This program could be executed [e.g.] by the command line...

node path/to/example/above.js load=some/module/to/load

Of course the load= is optional

Tested with node renamed to nodex on linux...all seems good.

comment:7 Changed 8 years ago by bill

Milestone: tbd1.8

comment:8 Changed 8 years ago by ben hockey

#14916 is a duplicate of this ticket.

comment:9 Changed 8 years ago by Colin Snover

Keywords: backport added
Milestone: 1.81.7.3
Priority: highblocker
Resolution: fixed
Status: closedreopened

Please backport to 1.7 branch.

comment:10 Changed 8 years ago by Colin Snover

Status: reopenedassigned

comment:11 Changed 8 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

In [28399]:

backported fix for #14540; fixes #14540; !strict

Note: See TracTickets for help on using tickets.