Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

machine

Package Overview
Dependencies
Maintainers
5
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machine - npm Package Compare versions

Comparing version 13.0.0-10 to 13.0.0-11

17

lib/intercept-exit-callbacks.js

@@ -41,5 +41,7 @@ /**

// Set the `._exited` property to indicate that the machine instance's `fn`
// has attempted to trigger an exit callback.
machine._exited = exitName;
// Assert that our `_exited` spinlock has not already been set.
if (machine._exited) {
console.warn('In machine `'+_.camelCase(machine.identity)+'`: attempted to call exit `'+exitName+'` after exit `'+machine._exited+'` was already triggered. If you are the maintainer of this machine, make sure your machine only ever calls one exit, exactly once!');
return;
}

@@ -102,2 +104,5 @@ // If appropriate, cache the output

else {
// Clear the spinlock.
// In this special case, it's okay to call an exit (error) after another exit
// has already been triggered.
return memo.error(new Error('Invalid example for `'+exitName+'` exit: '+util.inspect(example, false, null)));

@@ -113,3 +118,3 @@ }

// In order to allow for synchronous usage, `async` must be explicitly `true`.
// In order to allow for synchronous usage, `sync` must be explicitly `true`.
if (machine._runningSynchronously) {

@@ -167,2 +172,6 @@ return cb();

// Set the `._exited` property to indicate that the machine instance's `fn`
// has attempted to trigger an exit callback.
machine._exited = exitName;
// Call the configured callback for this exit

@@ -169,0 +178,0 @@ return fn.call(machine._configuredEnvironment, value);

@@ -40,3 +40,18 @@ /**

// Assert that our `_started` spinlock has not already been set.
// (better to terminate the process than trigger a callback twice)
if (self._started) { throw new Error('Cannot call `.exec()` twice on the same live machine (machine `'+_.camelCase(self.identity)+'` already started running). To run a machine multiple times, please configure it each time to get a new instance.'); }
// Set the _started spinlock so that this live machine cannot be `exec()`d again.
self._started = true;
// Create an error instance so that we have a clean stack trace leading back to the
// calling machine. We'll use this below when we build forwarding callbacks for
// miscellaneous exits, to give them better output messages.
var cleanError = new Error();
// Lop off the first line of the stack trace, which we'll replace
// with a better message below.
cleanError.stack = cleanError.stack.split('\n').slice(1).join('\n');
// If duration-tracking is enabled, track current timestamp

@@ -606,19 +621,34 @@ // as a JavaScript Date instance in `_execBeginTimestamp`.

// Build an error instance.
var errMsg = '`'+self.identity+'` triggered its `'+exitCodeName+'` exit';
// Start building the error message.
var errMsg = '`'+_.camelCase(self.identity)+'` triggered its `'+exitCodeName+'` exit';
// Use the description, if one was provided.
var exitDef = self.exits[exitCodeName];
if (!_.isObject(exitDef)) { throw new Error('Consistency violation: Live machine instance ('+self.identity+') has become corrupted! One of its exits (`'+exitCodeName+'`) has gone missing _while the machine was being run_!'); }
if (exitDef.description) {
errMsg += ': '+self.exits[exitCodeName].description;
// If no result was passed in to the exit, append the exit description if available.
if (_.isUndefined(_resultPassedInByMachineFn)) {
// Use the description, if one was provided.
var exitDef = self.exits[exitCodeName];
if (!_.isObject(exitDef)) { throw new Error('Consistency violation: Live machine instance ('+self.identity+') has become corrupted! One of its exits (`'+exitCodeName+'`) has gone missing _while the machine was being run_!'); }
if (exitDef.description) {
errMsg += ': '+self.exits[exitCodeName].description;
}
}
// If an Error was passed in to the exit, append its message
else if (_.isError(_resultPassedInByMachineFn)) {
errMsg += ': '+_resultPassedInByMachineFn.message;
}
// If a non-Error was passed in to the exit, inspect and append it
else if (!_.isError(_resultPassedInByMachineFn)) {
errMsg += ' with: \n\n' + util.inspect(_resultPassedInByMachineFn, {depth: null});
}
// Construct the error instance, then add the `exit` property.
// (also set `code` for compatibility)
var err_forwarding = new Error(errMsg);
// Get a local reference to the clean error we created at the top of this file.
// We know cleanError will only be used once since we implemented a spinlock via
// the "_exited" property of the machine (see intercept-exit-callbacks).
var err_forwarding = cleanError;
// Copy our error message
err_forwarding.message = errMsg;
err_forwarding.stack = 'Error: ' + errMsg + '\n' + err_forwarding.stack;
err_forwarding.exit = exitCodeName;
err_forwarding.code = exitCodeName;
// If a result was passed in, it will be stuff it in the generated Error instance
// If a result was passed in, stuff it in the generated Error instance
// as the `output` property.

@@ -700,4 +730,3 @@ if (!_.isUndefined(_resultPassedInByMachineFn)) {

// (better to terminate the process than trigger a callback twice)
if (self._exited) { throw new Error('The timeout alarm was triggered when `_exited` was already set. Perhaps you called `.exec()` more than once? If so, please fix and try again.'); }
self._exited = 'error';
if (self._exited) { throw new Error('Consistency violation: the timeout alarm was triggered when `_exited` was already set.'); }

@@ -704,0 +733,0 @@ var err = new Error(

{
"name": "machine",
"version": "13.0.0-10",
"version": "13.0.0-11",
"description": "Configure and execute machines",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc