Giter Club home page Giter Club logo

driver's Issues

HeuristicWeight should be allowed to be higher than 9

let heuristicWeight = Math.min(9, Math.max(1, options.heuristicWeight || 1.2));

There is no reason for the heuristicWeight to be limited to only 9.
Actually this has lead to some unexpected results:
https://screeps.com/forum/topic/2768/pathfinder-using-heuristicweight-to-implement-fractional-costs

I propose to remove that upper limit or choose a very high limit. The user that sets a heuristicWeight that high knows what (s)he's doing and would just be surprised of the high cpu costs that happen because it's actually capped to 9 (undocumented as well).

Missing STD <limits> Headers for GCC 11+

The Problem

It appears that with GCC11 some headers with libstdc must be explicitly included. Namely, <limits>

Reference: Porting to GCC11 - Header Dependency Changes

Versions Replicated On

  • Screeps 3.4.0
  • Python 2.7
  • GCC 11.2.1
  • Node 16.13.0
  • node-gyp 3.8.0
  • OS: Fedora 35

Steps to Replicate

npm init
npm i screeps

Resulting Output

npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Scroll issue in Chrome fixed in version 1.0.5
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path /mnt/kube-storage/Screeps/node_modules/@screeps/driver
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild -C native && webpack
npm ERR! make: Entering directory '/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native/build'
npm ERR!   CXX(target) Release/obj.target/native/src/main.o
npm ERR! make: Leaving directory '/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info chdir native
npm ERR! (node:3226283) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/mnt/kube-storage/Screeps/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/mnt/kube-storage/Screeps/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/mnt/kube-storage/Screeps/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/main.cc:5:
npm ERR! ../src/pf.h:16:28: error: ‘numeric_limits’ is not a member of ‘std’
npm ERR!    16 |         static_assert(std::numeric_limits<pos_index_t>::max() > 2500 * k_max_rooms, "pos_index_t is too small");
npm ERR!       |                            ^~~~~~~~~~~~~~
npm ERR! ../src/pf.h:16:54: error: expected primary-expression before ‘>’ token
npm ERR!    16 |         static_assert(std::numeric_limits<pos_index_t>::max() > 2500 * k_max_rooms, "pos_index_t is too small");
npm ERR!       |                                                      ^
npm ERR! ../src/pf.h:16:57: error: ‘::max’ has not been declared; did you mean ‘std::max’?
npm ERR!    16 |         static_assert(std::numeric_limits<pos_index_t>::max() > 2500 * k_max_rooms, "pos_index_t is too small");
npm ERR!       |                                                         ^~~
npm ERR!       |                                                         std::max
npm ERR! In file included from /usr/include/c++/11/algorithm:62,
npm ERR!                  from ../../../../nan/nan.h:61,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
npm ERR!  3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
npm ERR!       |     ^~~
npm ERR! In file included from ../src/main.cc:5:
npm ERR! ../src/pf.h: In member function ‘void screeps::open_closed_t<capacity>::clear()’:
npm ERR! ../src/pf.h:186:42: error: ‘numeric_limits’ is not a member of ‘std’
npm ERR!   186 |                                 if (std::numeric_limits<marker_t>::max() - 2 <= marker) {
npm ERR!       |                                          ^~~~~~~~~~~~~~
npm ERR! ../src/pf.h:186:65: error: expected primary-expression before ‘>’ token
npm ERR!   186 |                                 if (std::numeric_limits<marker_t>::max() - 2 <= marker) {
npm ERR!       |                                                                 ^
npm ERR! ../src/pf.h:186:68: error: ‘::max’ has not been declared; did you mean ‘std::max’?

npm ERR!   186 |                                 if (std::numeric_limits<marker_t>::max() - 2 <= marker) {
npm ERR!       |                                                                    ^~~
npm ERR!       |                                                                    std::max
npm ERR! In file included from /usr/include/c++/11/algorithm:62,
npm ERR!                  from ../../../../nan/nan.h:61,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
npm ERR!  3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
npm ERR!       |     ^~~
npm ERR! In file included from ../src/main.cc:5:
npm ERR! ../src/pf.h: At global scope:
npm ERR! ../src/pf.h:342:65: error: ‘numeric_limits’ is not a member of ‘std’
npm ERR!   342 |                         static constexpr cost_t obstacle = std::numeric_limits<cost_t>::max();
npm ERR!       |                                                                 ^~~~~~~~~~~~~~
npm ERR! ../src/pf.h:342:86: error: expected primary-expression before ‘>’ token
npm ERR!   342 |                         static constexpr cost_t obstacle = std::numeric_limits<cost_t>::max();
npm ERR!       |                                                                                      ^
npm ERR! ../src/pf.h:342:89: error: ‘::max’ has not been declared; did you mean ‘std::max’?
npm ERR!   342 |                         static constexpr cost_t obstacle = std::numeric_limits<cost_t>::max();
npm ERR!       |                                                                                         ^~~
npm ERR!       |                                                                                         std::max
npm ERR! In file included from /usr/include/c++/11/algorithm:62,
npm ERR!                  from ../../../../nan/nan.h:61,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
npm ERR!  3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
npm ERR!       |     ^~~
npm ERR! In file included from ../../../../nan/nan.h:58,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /root/.node-gyp/16.13.0/include/node/node.h:821:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR!   821 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.node-gyp/16.13.0/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR!   855 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/main.cc:63:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!    63 | NODE_MODULE(native, init);
npm ERR!       | ^~~~~~~~~~~
npm ERR! make: *** [native.target.mk:209: Release/obj.target/native/src/main.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/mnt/kube-storage/Screeps/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.15.6-200.fc35.x86_64
npm ERR! gyp ERR! command "/usr/bin/node" "/mnt/kube-storage/Screeps/node_modules/.bin/node-gyp" "rebuild" "-C" "native"
npm ERR! gyp ERR! cwd /mnt/kube-storage/Screeps/node_modules/@screeps/driver/native
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-19T01_56_46_657Z-debug.log

[Beta.8] publicSegments breaks user code

In the current ivm betas there is a bug breaking publicSegment lists, it is attempting to run join(',') twice, resulting in an error for the second attempt.

env.set(env.keys.PUBLIC_MEMORY_SEGMENTS+userData.user._id, runResult.publicSegments.join(','));

outMessage.publicSegments = publicSegments.join(',');

I can make a PR if desired, which of the two lines needs to be edited? Currently, on S+ I've just removed .join(',') from the make.js line, thus solving it.

Recommended shutdown method?

The driver doesn't seem to export a disconnect or shutdown method. After shutting down the processes I've spawned for other modules, I get the following error non-stop until the process that called connect() on the driver is stopped

Connecting to storage
Storage connection lost { Error: connect ECONNREFUSED 127.0.0.1:21025
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 21025 }
Connecting to storage
Storage connection lost { Error: connect ECONNREFUSED 127.0.0.1:21025
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 21025 }
Connecting to storage
Storage connection lost { Error: connect ECONNREFUSED 127.0.0.1:21025
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 21025 }

It looks like that is the result of a retry that exists in the common storage _connect() method that has an unending connect retry here https://github.com/screeps/common/blob/master/lib/storage.js#L150

Does a way exist to shutdown the driver so that these continuous attempts at connecting to killed processes will stop? And if not, is there a recommended way of starting the driver to prevent this kind of output?

isolated-vm outdated

It seems that isolated-vm required (2.0.1) is too old (the last version is 3.3.7), causing build error on Nodejs LTS 14

PTR: Promises are back

Promises were disabled in #6 to prevent timeout skipping, with PTR on Node 7.9 Promises can be restored and used via the new async/await feature as seen below, this effectively readds the Promise class to global.

    let promise = async function(){ return '' }
    global.Promise = promise().constructor

shardName should not be blank

shardName: ''

This should match the value in Game.shards.name for consistency, and remain moddable. Even better if we could set it via config.engine like other options ;)
Could just add shardName: os.hostname() to the config object at the top, and reference that in both the Game.shards building and this.

driver.getAllRooms was removed in 5.1.0

This is more informational than a complaint, but it seems that driver.getAllRooms was removed from the API in the latest minor release 5.1.0. see: 18bcfce

This ended up breaking @screepers/screeps-server-mockup because we were using this function to fetch all of the rooms of interest. I did not expect a breaking change such as a reduction in API surface to come from a minor release update.

Luckily, it was a pretty simple fix to get updated. Just wanted to give you guys insight into compatibility issues which can arise.

Feel free to ACK and close this once it has been noted

Required dependencies are missing from package.json

I cloned the repository and ran into a few issues when I tried to set it up.

> [email protected] install /Users/RA80533/Desktop/screeps/driver/node_modules/fsevents
> node install

  SOLINK_MODULE(target) Release/.node
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  SOLINK_MODULE(target) Release/fse.node
  COPY /Users/RA80533/Desktop/screeps/driver/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node
  COPY /Users/RA80533/Desktop/screeps/driver/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp
  TOUCH Release/obj.target/action_after_build.stamp

> [email protected] install /Users/RA80533/Desktop/screeps/driver/node_modules/isolated-vm
> node-gyp rebuild --release -j 4

  CXX(target) Release/obj.target/nortti/src/external_copy_nortti.o
  LIBTOOL-STATIC Release/nortti.a
  CXX(target) Release/obj.target/isolated_vm/src/isolate/allocator.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/class_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/environment.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/holder.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/inspector.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/stack_trace.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/three_phase_task.o
  CXX(target) Release/obj.target/isolated_vm/src/context_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/external_copy.o
  CXX(target) Release/obj.target/isolated_vm/src/external_copy_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/lib_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/native_module_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/reference_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/script_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/module_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/session_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/transferable.o
  SOLINK_MODULE(target) Release/isolated_vm.node

> [email protected] postinstall /Users/RA80533/Desktop/screeps/driver/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> @screeps/[email protected] install /Users/RA80533/Desktop/screeps/driver
> node-gyp rebuild -C native && webpack

  CXX(target) Release/obj.target/native/src/main.o
  CXX(target) Release/obj.target/native/src/pf.o
  SOLINK_MODULE(target) Release/native.node
Executing post-build scripts
Hash: 2f277a711aa7386a2fe6
Version: webpack 3.11.0
Time: 244ms
            Asset    Size  Chunks                    Chunk Names
runtime.bundle.js  498 kB       0  [emitted]  [big]  main
   [0] (webpack)/buildin/global.js 509 bytes {0} [built]
   [2] ./lib/runtime/runtime.js 9.93 kB {0} [built]
   [3] ./lib/runtime/mapgrid.js 7.09 kB {0} [built]
   [4] ./lib/runtime/runtime-driver.js 4.09 kB {0} [built]
   [9] (webpack)/buildin/module.js 517 bytes {0} [built]
  [10] ./lib/path-finder.js 5 kB {0} [built]
    + 5 hidden modules

ERROR in ./lib/runtime/runtime-driver.js
Module not found: Error: Can't resolve '@screeps/common/lib/constants' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime-driver.js 11:20-60
 @ ./lib/runtime/mapgrid.js
 @ ./lib/runtime/runtime.js

ERROR in ./lib/runtime/runtime-driver.js
Module not found: Error: Can't resolve '@screeps/common/lib/system' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime-driver.js 12:17-54
 @ ./lib/runtime/mapgrid.js
 @ ./lib/runtime/runtime.js

ERROR in ./lib/runtime/runtime.js
Module not found: Error: Can't resolve '@screeps/engine/src/game/console' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime.js 3:24-67

ERROR in ./lib/runtime/runtime.js
Module not found: Error: Can't resolve '@screeps/engine/src/game/game' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime.js 2:17-57

ERROR in ./lib/runtime/runtime.js
Module not found: Error: Can't resolve '@screeps/engine/src/utils' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime.js 5:18-54

ERROR in ./lib/runtime/mapgrid.js
Module not found: Error: Can't resolve '@screeps/pathfinding' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/mapgrid.js 1:18-49
 @ ./lib/runtime/runtime.js
Runtime snapshot created (2656724 bytes)

I took a peek at the files referenced in the errors. It looks like they reference a few missing dependencies, namely:

  • @screeps/common is required in lib/bulk.js (line 3), lib/history.js (line 3), lib/index.js (line 4), lib/queue.js (line 4), lib/runtime/data.js (line 4), lib/runtime/make.js (line 1), lib/runtime/runtime-driver.js (lines 11 and 12), and lib/runtime/user-vm.js (line 8)
  • @screeps/engine is required by lib/runtime/runtime.js (lines 2, 3, and 5)
  • @screeps/pathfinding is required by lib/runtime/mapgrid.js (line 1)

Driver won't install

I'm trying to do npm install -g @screeps/driver since it doesn't seem to be a dependency of screeps/engine, and am receiving the following error:

> @screeps/[email protected] install /home/adam/npm-global/lib/node_modules/@screeps/driver
> node-gyp rebuild -C native

module.js:471
    throw err;
    ^

Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.exports.runInThisContext (vm.js:77:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:570:32)
    at bootstrap_node.js:357:29
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/adam/npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-28-generic
gyp ERR! command "/opt/node/bin/node" "/home/adam/npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "-C" "native"
gyp ERR! cwd /home/adam/npm-global/lib/node_modules/@screeps/driver/native
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

Update to Python 3

On the main page of the screeps server it states only Python 2 is supported. Meanwhile there have been some updates to node-gyp and now supports Python 3. From version 5.0.4 I believe.

I would like to add support for the newer node-gyp version. Installing node-gyp using Python 3.10.8 was succesfull.

However I am not completely familiar with the npm enviroment. So when testing the driver module this was the error message.

code 1
npm ERR! path /Users/hayer/driver/node_modules/isolated-vm
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild --release -j 4
npm ERR! CXX(target) Release/obj.target/nortti/src/external_copy_nortti.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.10.8 found at "/Users/hayer/.pyenv/versions/3.10.8/bin/python3"
npm ERR! gyp info spawn /Users/hayer/.pyenv/versions/3.10.8/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/hayer/driver/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/hayer/driver/node_modules/isolated-vm/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/hayer/driver/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/hayer/Library/Caches/node-gyp/14.21.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/hayer/Library/Caches/node-gyp/14.21.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/hayer/driver/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/hayer/Library/Caches/node-gyp/14.21.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/hayer/driver/node_modules/isolated-vm',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 4 ]
npm ERR! In file included from ../src/external_copy_nortti.cc:1:
npm ERR! In file included from ../src/external_copy.h:10:
npm ERR! ../src/isolate/util.h:28:75: error: no viable conversion from 'const v8::Local<v8::Context>' to 'v8::Isolate *'
npm ERR!         return Unmaybe(Unmaybe(options->Get(context, v8_string(key)))->ToBoolean(context))->IsTrue();
npm ERR!                                                                                  ^~~~~~~
npm ERR! /Users/hayer/Library/Caches/node-gyp/14.21.1/include/node/v8.h:2848:37: note: passing argument to parameter 'isolate' here
npm ERR!   Local<Boolean> ToBoolean(Isolate* isolate) const;
npm ERR!                                     ^
npm ERR! In file included from ../src/external_copy_nortti.cc:1:
npm ERR! In file included from ../src/external_copy.h:10:
npm ERR! ../src/isolate/util.h:28:9: error: no matching function for call to 'Unmaybe'
npm ERR!         return Unmaybe(Unmaybe(options->Get(context, v8_string(key)))->ToBoolean(context))->IsTrue();
npm ERR!                ^~~~~~~
npm ERR! ../src/isolate/util.h:10:36: note: candidate template ignored: could not match 'MaybeLocal' against 'Local'
npm ERR! template <typename T> v8::Local<T> Unmaybe(v8::MaybeLocal<T> handle);
npm ERR!                                    ^
npm ERR! ../src/isolate/util.h:11:25: note: candidate template ignored: could not match 'Maybe' against 'Local'
npm ERR! template <typename T> T Unmaybe(v8::Maybe<T> handle);
npm ERR!                         ^
npm ERR! 2 errors generated.
npm ERR! make: *** [Release/obj.target/nortti/src/external_copy_nortti.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/hayer/driver/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
npm ERR! gyp ERR! System Darwin 22.3.0
npm ERR! gyp ERR! command "/Users/hayer/.local/share/nvm/v14.21.1/bin/node" "/Users/hayer/driver/node_modules/.bin/node-gyp" "rebuild" "--release" "-j" "4"
npm ERR! gyp ERR! cwd /Users/hayer/driver/node_modules/isolated-vm
npm ERR! gyp ERR! node -v v14.21.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

Time sometimes goes backwards for a moment

My hypothesis is that this read is not atomic, the high bits are read, then the timer rolls over to a new high bit, the low bits have gone from max to min value when they roll over, and now the low bits are read.

Before the call to getUsed the timer may have been

0xFAFF

Now it's

0xFB00

The JavaScript code reads

0xFA00

(Numbers not to scale)

return isolate.cpuTime[0] * 1e3 + isolate.cpuTime[1] / 1e6;

I believe if cpuTime is copied to a local value first, and then destructed [0], [1]. Time will no longer go backwards and getUsed will never be negative

Cheers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.