question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pass async to end-user on start & end for sandbox

See original GitHub issue

This was discussed in slack.

Is your feature request related to a problem? Please describe.

Currently, require('@architect/sandbox') end and start functions swallow the callbacks , so end-user has no access to err or when the close has asynchronously finished. This is a sign that global async queue is being used, and breaks things like testing in jest (as it uses atomic async tests & before/after, not global queue.) It’s not just a problem with testing though, it would break anything where you need to do something after start or end.

Describe the solution you’d like

If async were not swallowed, end-user could trigger their function when it’s done. I like promises, in general, and some will like callbacks, so this, as an example, supports both uses:

const { promisify } = require('util')

function end(cb = () => {}) {
  return Promise.all(
    promisify(client.close)(),
    promisify(bus.close)(),
  ).then(() => {
    if ((arc.http || arc.ws) {
      return  promisify(http.close)().then(promisify(cb))
    }else{
      return promisify(cb)()
    }
  })
}

this resolves when client & bus close methods have been called in parallell, then http and user’s callback. It returns a promise, and if the user gave a callback, it uses that (instead of requiring user to use a promise.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanblockcommented, Jan 31, 2020

Diff module’s side effects, let’s scope that bug to that module. This fix will ship in 1.6.0!

1reaction
ryanblockcommented, Jan 31, 2020

I think we just crossed paths here and on Slack! I think I’ve managed to resolve all issues in 1.5.9-RC, please npm i @architect/sandbox@RC and let me know how it goes.

Per the Dynamo client thing, I worked around that by putting that operation into a callback fn, seems fine and more deterministic, so that’s a nice bonus. 📈

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't the VM sandbox run code asynchronously? #80 - GitHub
But I just don't need the value that is returned immediately after vm.run . I'm looking for a way to do something like...
Read more >
FelipeLema/session-async.el: Asynchonous processing in ...
Create a new session that can be used with several session-async-future or session-async-start calls. This wraps an Emacs process running in the background....
Read more >
async-rule-evaluator - npm
A dynamic rule evaluation DSL that supports lazy and asynchronous data resolution. Latest version: 1.7.0, last published: 2 years ago. Start ...
Read more >
Quickstart | Plaid Docs
Follow these instructions to start building with Plaid. You will learn about our API keys, development environments, and more.
Read more >
Workflow best practices - Knowledge Center - Zuora
Fully test your workflows in Sandbox before deploying them to Production ... all the designed scenarios before it gets deployed for end-user testing....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found