profile
viewpoint

benjamingr/bluebird-api 36

Bluebird compatible API on top of native promises.

benjamingr/Auto-Translate 4

Translating multiple languages in JS/HTML through JSON seamlessly

addaleax/node 3

Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:

benjamingr/blaze-lib 1

Automatically exported from code.google.com/p/blaze-lib

benjamingr/act 0

A simple reactive front-end framework

benjamingr/analytics.js-integration-auryc 0

Segment Auryc Javascript Integration

benjamingr/angular.js 0

HTML enhanced for web apps

benjamingr/ApplicationInsights-node.js 0

Microsoft Application Insights SDK for node.js

benjamingr/Array.prototype.includes 0

Spec, tests, reference implementation, and docs for ESnext-track Array.prototype.includes

benjamingr/async-hooks-performance-impact 0

Performance impact of async_hooks

Pull request review commenttestimio/TDK-kitchensink

TES-4517-added a test for multi tab

+# This is an example of handling iframes

add some text explaining what this is showing.

DanielTestim

comment created time in 16 hours

delete branch testimio/TDK-kitchensink

delete branch : adding-to-kitchensink-project

delete time in 17 hours

pull request commenttestimio/TDK-kitchensink

Adding to kitchensink project

And please keep things in pull requests.

DanielTestim

comment created time in 17 hours

pull request commenttestimio/TDK-kitchensink

Adding to kitchensink project

You committed node_modules, please add it to gitignore and remove it from git (and wipe it from git).

DanielTestim

comment created time in 17 hours

pull request commentnodejs/node

module: recover on statCache failure

@guybedford I believe a --no-stat-cache flag would be the opposite of not exposing this behavior any more to our users :] I would prefer require.clean to a --no-stat-cache flag since require.clean would be available to libraries.

benjamingr

comment created time in 2 days

pull request commentnodejs/node

module: recover on statCache failure

Note this doesn't consistently support cases where an inner fallback is added after the fact

Right, that's a very good point. This is an improvement IMO but we still expose a lot of internal caching behavior unintentionally. I would get behind anything that improves consistency without causing a performance regression.

I think that it's easy to add a requireWithoutCache function or an explicit .clear() but that would mean exposing behavior we currently keep as implementation detail.

From a user point of view I would expect actual modules to be cached but everything else to not be cached - if node wants to cache things "under the hood" they (we) shouldn't surprise the user.

benjamingr

comment created time in 2 days

pull request commentnodejs/node

module: recover on statCache failure

Altering the dependency chain at runtime is something most of us would not like in production servers.

I ran into this issue in a CLI tool (and not a server). A common use case for lazy dependency installation is having a CLI that does several things and you don't want to bring in hundreds of megabytes ahead of time.

Currently this works just fine if the require is async but if it's synchronous the user is exposed to our caching behaviour.

I am fine with never working by default (freezing the dependency chain) or always working - it's the "asynchronously working but not synchronously when you try/catch" which I find surprising.

benjamingr

comment created time in 3 days

Pull request review commentnodejs/node

stream: fix broken pipeline error propagation

 function pipeline(...streams) {         const pt = new PassThrough();         if (isPromise(ret)) {           ret+            .catch((err) => {+              pt.destroy(err);+            })             .then((val) => {+              value = val;               pt.end(val);

Yes, exactly. It wasn't wrong it was just confusing :]

ronag

comment created time in 3 days

Pull request review commentnodejs/node

module: recover on statCache failure

 Module.prototype.require = function(id) {   requireDepth++;   try {     return Module._load(id, this, /* isMain */ false);+  } catch (e) {+    if (e.code === 'MODULE_NOT_FOUND') {+      // A module might be created synchronously in which case Node might+      // errornously not find it - so try again without the statCache+      const oldStatCache = statCache;+      statCache = new Map();+      try {+        return Module._load(id, this, /* isMain */ false);

The assumption I made is that if the second attempt succeeded someone "touched the filesystem" which potentially invalidates a lot of requests. I would prefer future requests to perform stat calls rather than perform a retry without the cache each time (and merge).

I am not sure this is the right assumption to make - if you think the case where throwing away the statCache hurts performance is more common in the real world I can optimise for that instead.

It would be easy to make a benchmark that optimises for either assumption and when I tested it in two "real world" code bases I have access to I didn't get a meaningful difference between the two.

For reference, here is a diff if you want to test a version that merges on success:

diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 3f4c37b6c1..0ca37bfd87 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1098,7 +1098,9 @@ Module.prototype.require = function(id) {
       const oldStatCache = statCache;
       statCache = new Map();
       try {
-        return Module._load(id, this, /* isMain */ false);
+        const loadResult = Module._load(id, this, /* isMain */ false);
+        statCache = new Map([...oldStatCache, ...statCache])
+        return loadResult;
       } catch (e) {
         // If it failed, nothing was wrong with the statCache and this was
         // just a conditional require so restore it
benjamingr

comment created time in 3 days

push eventbenjamingr/io.js

Benjamin Gruenbaum

commit sha 3126c500462782a093c2505dc833aa8428041638

module: recover on statCache failure Fixes: https://github.com/nodejs/node/issues/31803 PR-URL: https://github.com/nodejs/node/pull/31921

view details

push time in 3 days

PR opened nodejs/node

Reviewers
module: recover on statCache failure
Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

  • [x] make -j4 test (UNIX), or vcbuild test (Windows) passes
  • [x] tests and/or benchmarks are included
  • [ ] documentation is changed or added
  • [x] commit message follows commit guidelines

Hey, this is an attempt to resolve the use cases in https://github.com/nodejs/node/issues/31803 and only pay the penalty on unsuccessful loads.

This means that conditional loads are slightly slower (since we attempt them again without the statCache) but all other loads should be as fast and the caching behaviour is less exposed to the user.

I think this is a reasonable tradeoff between not regressing the common pattern of conditional requires while still enabling synchronous resource creation.

+33 -0

0 comment

2 changed files

pr created time in 3 days

create barnchbenjamingr/io.js

branch : require-cache-clear-on-fail

created branch time in 3 days

pull request commentnodejs/node

http,stream: make virtual methods throw an error

LGTM with semver-major and citgm

lpinca

comment created time in 3 days

Pull request review commentnodejs/node

stream: fix broken pipeline error propagation

 function pipeline(...streams) {         const pt = new PassThrough();         if (isPromise(ret)) {           ret+            .catch((err) => {+              pt.destroy(err);+            })             .then((val) => {+              value = val;               pt.end(val);

This means that .end will be called and value will be undefined. This is a bit confusing.

ronag

comment created time in 4 days

issue commentnodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

What if we only retry failed attempts without the statCache? That way we would only pay the penalty of not going through the cache failed attempts.

benjamingr

comment created time in 4 days

issue commentpetkaantonov/bluebird

At Promise fromNode fromCallback - a promise was created but was not returned from it

You have a promise somewhere you create in a .then but forgot to return. Turn on long stack traces and figure it out :]

In general, please open support requests according to http://bluebirdjs.com/docs/support.html

mercteil

comment created time in 7 days

MemberEvent

created repositorytestimio/TDK-kitchensink

Contains examples of TDK tests and patterns.

created time in 10 days

issue commentnodejs/help

require.resolve() for executables

Hey @ORESoftware what did you end up doing here?

ORESoftware

comment created time in 10 days

issue commentnodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

@targos

Does require.resolve have the same restriction?

It does, it goes through Module._findPath and uses the stat cache.

@bnoordhuis

The time for installing packages is at install time, not run time.

Package installation is just one use case - the only reason Node works this way at the moment is because we have caching for performance reasons and that is observable. Moreover we have already worked around it in the REPL.

@mcollina

Hmm, if it only invalidated the entries it created for the problematically required module rather than the whole cache on an error would it help?

@mscdex

Perhaps there should be an explicit API to do this instead of always doing it, so that you opt-in to any potential performance issues.

I tend to agree though I believe the current behavior is only because our performance optimization leaks a behavioral change.

benjamingr

comment created time in 11 days

issue openednodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

Currently, it is impossible to write code like:

let Bluebird;
try { 
  Bluebird = require('bluebird');
} catch (e) { 
  execSync('npm install bluebird');
  Bluebird = require('bluebird');
} 

Because the cjs loader caches the results of stat calls internally so it would not look for bluebird the second time we require it.

It would be pretty easy to deal with this use case from a technical point of view by setting statCache to a new Map() on a MODULE_NOT_FOUND.

I can see several use cases like:

  • Writing repls in userland
  • Writing a "lazy loading" require hook that recovers from 'module not found' errors by npm install`

Would people be in favor of this change and enabling this?

cc @nodejs/modules

cc @BridgeAR because of https://github.com/nodejs/node/pull/26928 that enables this specifically for the REPL.

created time in 11 days

pull request commentnodejs/node

crypto: fixes performance regression

I am personally in favor of landing with the changes - including the regressions. Mostly because the regressions aren't big and the benchmarks are very positive.

ronag

comment created time in 12 days

pull request commentcoralogix/nodejs-coralogix-sdk

TES-4800 allow exposing waitForFlush capability

This PR addresses an issue where logs are dropped if the Node server is shut-down by exposing an API letting coralogix-logger wait for logs to be sent from the backend.

The original issue is very easy to reproduce. You can call:

tester.addDemoLine();
process.exit();
```

In tester.ts to see that it's not sent to the backend :]
benjamingr

comment created time in 15 days

push eventtestimio/nodejs-coralogix-sdk

Benjamin Gruenbaum

commit sha 2c2c9babb2e7faaa24c4b360708b06f5076dd9d5

Remove `.only` when testing :]

view details

push time in 16 days

PR opened coralogix/nodejs-coralogix-sdk

TES-4800 allow exposing waitForFlush capability

Hey,

As discussed on email.

  • I added a test to help you accept the code. I tried running the linter but it did not pass on master. I made sure not to introduce any new lint issues.
  • I noticed dist is committed so I ran a build - I would recommend removing it from the repo as it is derived from the source.

Cheers and love, Benji and Moshe

+152 -4

0 comment

9 changed files

pr created time in 16 days

issue commentcloudflare/lol-html

Implement WASM-based JS API

That's tricky since I don't actually understand how to use it but once there are docs I would be happy to contribute some tests :)

inikulin

comment created time in 23 days

issue commentcloudflare/lol-html

Implement WASM-based JS API

Any way I can help promote or push this?

inikulin

comment created time in 24 days

pull request commentsindresorhus/to-fast-properties

Fix Node.js 12 compatibility

Sure thing 😘

benjamingr

comment created time in 25 days

push eventpetkaantonov/bluebird

Benjamin Gruenbaum

commit sha 78e382370cf6275b82fded81d2a6e6699e5f440a

Update util.js

view details

push time in a month

issue commentgiggio/node-chromedriver

DETECT_CHROMEDRIVER_VERSION doesn't work on mac

We were able to verify the bug - the \n was just not important the way we used chrome-version internally.

CC @eladrkatz who actually did the work 😅

kellyselden

comment created time in a month

issue closedtestimio/chrome-version

Fix google chrome version detection for MacOS

Please see: https://github.com/giggio/node-chromedriver/pull/248

closed time in a month

giggio

issue commenttestimio/chrome-version

Fix google chrome version detection for MacOS

Thanks for the quick fix ❤️

giggio

comment created time in a month

issue commenttestimio/chrome-version

Fix google chrome version detection for MacOS

@eladrkatz can you please spend an hour or two looking at this today?

giggio

comment created time in a month

issue closednodejs/node

Nominating Robert Nagy @ronag to be a collaborator

Original internal nomination by @gireeshpunathil :]

Hey,

I would like to nominate @ronag (Robert Nagy) to be a Node.js core collaborator. They have made solid contributions to http, streams and http2 over a long period.

They have shown ability to make meaningful changes in the code and have hundreds of PRs and commits. I was actually quite surprised when I realized they were not a collaborator already and I think they would make a good addition to core.

Contribution history: https://github.com/pulls?utf8=%E2%9C%93&q=author%3Aronag+org%3Anodejs+ https://github.com/search?p=6&q=org%3Anodejs+author%3Aronag&type=Issues

Please provide your feedback, or 👍 if you concur. thanks!

closed time in a month

benjamingr

issue commentnodejs/node

Nominating Robert Nagy @ronag to be a collaborator

Hey looks like this happened - awesome and congrats :)

benjamingr

comment created time in a month

issue closedgiggio/node-chromedriver

What to do about the day between chrome release and ChromeDriver release?

So, recent version of ChromeDriver only support a single version of Chrome - this means whenever Chrome updates and until you release this library (thank you a ton by the way) this library is broken.

Given Chrome releases once every 8 weeks and the releases are fairly predictable (here) it would be really great if there was a workaround for this.

I realise I can work around it by overriding the release string - and that this library is "blessed" by design but a "blessed" (heh) workaround for this would still be super helpful as currently our code breaks every 8 weeks as users upgrade.

Some ideas:

  • Publishing a beta version of this package with the beta version of Chrome
  • Publishing a version of a second unblessed chromedriver-unblessed package that tracks the chromedriver releases.
  • Anything else?

closed time in a month

benjamingr

issue commentgiggio/node-chromedriver

What to do about the day between chrome release and ChromeDriver release?

This is better - yes. Although I figured our ChromeDriver has a flag to bypass version detection and we might want to pass that by default.

benjamingr

comment created time in a month

push eventpetkaantonov/bluebird

Benjamin Gruenbaum

commit sha 18f9c56ef1a74967ed3d6c9fb99fc23bea23a721

I forgot bluebird has a lint that enforces spaces over tabs

view details

push time in a month

issue commentAutomattic/mongoose

bug: for await ... of is not loaded all document

Yes, although I am not sure I'd call it "fair" I've been a part of Node for like 5 years now and I still find our API super confusing :D

We are just mostly stuck with it.

hyeksu-j

comment created time in a month

push eventpetkaantonov/bluebird

Benjamin Gruenbaum

commit sha 95dc599d41ac99b51afcf7ea7374e2d0867da163

es5

view details

push time in a month

PR opened petkaantonov/bluebird

Reviewers
Fix toFastProperties
+19 -13

0 comment

1 changed file

pr created time in a month

create barnchpetkaantonov/bluebird

branch : benjamingr-patch-5

created branch time in a month

issue commentpetkaantonov/bluebird

toFastProperties is not working

https://github.com/sindresorhus/to-fast-properties/pull/13

@petkaantonov want me to update the bb impl as well?

GoBrianGo

comment created time in a month

PR opened sindresorhus/to-fast-properties

Reviewers
Make test pass in Node 13

Hey, the tests broke on Node 13 (see issue https://github.com/sindresorhus/to-fast-properties/issues/12 ) because we don't hit the IC enough :]

+6 -1

0 comment

1 changed file

pr created time in a month

issue commentsindresorhus/to-fast-properties

Tests fail with Node.js >= 12

Looks like the threshold was changed. Making a pull request.

nileshpatra

comment created time in a month

create barnchsindresorhus/to-fast-properties

branch : fix-fox-node-13

created branch time in a month

issue commentsindresorhus/to-fast-properties

Tests fail with Node.js >= 12

Sure, this probably needs an update. I'll take a look.

BTW I am not seeing failures on Node 12 - only Node 13:

benjamin@Benjamins-MacBook-Pro to-fast-properties (master) $ nvm use 12 benjamin@Benjamins-MacBook-Pro to-fast-properties (master) $ npm test

to-fast-properties@3.0.0 test /Users/benjamin/Documents/Projects/to-fast-properties node --allow-natives-syntax test.js && tsd

✔ main

✔ 1 test passed

benjamin@Benjamins-MacBook-Pro to-fast-properties (master) $ nvm use 13 benjamin@Benjamins-MacBook-Pro to-fast-properties (master) $ npm test

to-fast-properties@3.0.0 test /Users/benjamin/Documents/Projects/to-fast-properties node --allow-natives-syntax test.js && tsd

✖ main object has fast properties

✖ 1 test failed

Side Note: So, I wanted to check how to fix it (with the V8 unit tests) and I found that oddly this library is included in Chromium's source itself (in the devtools) :D (and bluebird too)

nileshpatra

comment created time in a month

issue commentAutomattic/mongoose

bug: for await ... of is not loaded all document

@vkarpov15 streams in Node are extremely confusing and actually have two modes: Push and pull.

You get to push mode by listening to the data event and to pull mode by listening to 'readable' event.

Streams only do backpressure correctly in pull mode. Async iterators in Node open the stream in pull mode which makes backpressure work and .next triggers pulling the next item.

hyeksu-j

comment created time in a month

issue commentcloudflare/lol-html

Implement WASM-based JS API

This is awesome 👏. Would love to use it.

inikulin

comment created time in a month

issue commentcheeriojs/cheerio

parse5 is about half the performance of htmlparser2

@inikulin I would, how can I promote this?

benjamingr

comment created time in a month

issue commentcheeriojs/cheerio

parse5 is about half the performance of htmlparser2

And honestly JSDom is so slow for what I'm using it for that I will have to end up and writing out my own parser (for my employer, not personally). It's just a big undertaking (~3-4 months) and we won't provide the same API (just like fast-mhtml above doesn't - it solves a subset).

We have ~60 second parse times for some large websites.

benjamingr

comment created time in a month

issue commentcheeriojs/cheerio

parse5 is about half the performance of htmlparser2

@frank-dspeed no it's not, it's only using it for benchmarks. RTFC :]

benjamingr

comment created time in a month

fork benjamingr/bullmq

BullMQ - Premium Message Queue for NodeJS based on Redis

https://docs.bullmq.io/

fork in a month

issue commentAutomattic/mongoose

bug: for await ... of is not loaded all document

Hey, if there is anything you would expect us to do differently in terms of how streams in node support async iterators?

hyeksu-j

comment created time in a month

push eventtestimio/mhtml-parser

Benjamin Gruenbaum

commit sha 1592b1e808af7ed620ce447fcc9b60267d8eb5f2

update dependencies

view details

push time in a month

issue commenttestimio/mhtml-parser

No or fractured images / base64 decode problem.

ping?

peko

comment created time in a month

pull request commentnodejs/node

stream: support passing generator functions into pipeline

@mcollina might be better at motivating this than me.

Talked to Matteo, I'm convined :]

ronag

comment created time in 2 months

Pull request review commentnodejs/node

stream: support passing generator functions into pipeline

 const cleanup = finished(rs, (err) => { }); ``` -### `stream.pipeline(...streams, callback)`+### `stream.pipeline(source, ...streams, callback)` <!-- YAML added: v10.0.0--->--* `...streams` {Stream} Two or more streams to pipe between.+changes:+  - version: REPLACEME+    pr-url: https://github.com/nodejs/node/pull/31223+    description: Add support for functions and generators.
    description: Add support for functions generators and async generators.
ronag

comment created time in 2 months

issue commentdenoland/deno

Promise exit behaviour

Deno still does the incorrect unsafe thing here, and not what we discussed face to face for what it's worth @ry

benjamingr

comment created time in 2 months

issue closedpetkaantonov/bluebird

cancel array of promises

I am using bluebird(3.7.2) with request-promise(4.2.5) to cancel the list of promises after a given time. The problem is if i cancel a individual promise it cancel without throwing any error.

` const Promise = require('bluebird'); const request_promise = Promise.promisify(require('request-promise')); Promise.config({ cancellation: true });

let r_promise = [request_promise({ method: 'get', uri: 'https://reqres.in/api/users?page=2' }).catch((error) => { console.error('error 1') }), request_promise({ method: 'get', uri: 'https://reqres.in/api/users?page=2' }).catch((error) => { console.error('error 1') })];

r_promise.forEach((row, index) => { row.cancel(); });

setTimeout(() => { Promise.all(r_promise).then(data => { console.log(data); }).catch(err => { console.log(err); }); }, 2000); `

Its generating a late observation observer error. By seeing error I think I am cancelling promises after promise handlers. Please correct me.

closed time in 2 months

vipinrana

issue commentpetkaantonov/bluebird

Proposal Bluebird.wrap

That's just Promise.resolve

bogdan

comment created time in 2 months

issue commentGoogleChrome/lighthouse

Deprecate the Lighthouse Chrome extension

:(

paulirish

comment created time in 2 months

pull request commentnodejs/node

module: add API for interacting with source maps

Still LGTM.

bcoe

comment created time in 2 months

push eventtestimio/mhtml-parser

dependabot[bot]

commit sha 96cb141e3f76553e49175b5d640e2a0e75993282

Bump handlebars from 4.1.2 to 4.5.3 Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3. - [Release notes](https://github.com/wycats/handlebars.js/releases) - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md) - [Commits](https://github.com/wycats/handlebars.js/compare/v4.1.2...v4.5.3) Signed-off-by: dependabot[bot] <support@github.com>

view details

Benjamin Gruenbaum

commit sha 61cae23af4b1e888fce9d029a5efb6de26f86700

Merge pull request #12 from testimio/dependabot/npm_and_yarn/handlebars-4.5.3 Bump handlebars from 4.1.2 to 4.5.3

view details

push time in 2 months

PR merged testimio/mhtml-parser

Bump handlebars from 4.1.2 to 4.5.3 dependencies

Bumps handlebars from 4.1.2 to 4.5.3. <details> <summary>Changelog</summary>

Sourced from handlebars's changelog.

v4.5.3 - November 18th, 2019

Bugfixes:

  • fix: add "no-prototype-builtins" eslint-rule and fix all occurences - f7f05d7
  • fix: add more properties required to be enumerable - 1988878

Chores / Build:

  • fix: use !== 0 instead of != 0 - c02b05f
  • add chai and dirty-chai and sinon, for cleaner test-assertions and spies, deprecate old assertion-methods - 93e284e, 886ba86, 0817dad, 93516a0

Security:

  • The properties __proto__, __defineGetter__, __defineSetter__ and __lookupGetter__ have been added to the list of "properties that must be enumerable". If a property by that name is found and not enumerable on its parent, it will silently evaluate to undefined. This is done in both the compiled template and the "lookup"-helper. This will prevent new Remote-Code-Execution exploits that have been published recently.

Compatibility notes:

  • Due to the security-fixes. The semantics of the templates using __proto__, __defineGetter__, __defineSetter__ and __lookupGetter__ in the respect that those expression now return undefined rather than their actual value from the proto.
  • The semantics have not changed in cases where the properties are enumerable, as in:
{
  __proto__: 'some string'
}
  • The change may be breaking in that respect, but we still only increase the patch-version, because the incompatible use-cases are not intended, undocumented and far less important than fixing Remote-Code-Execution exploits on existing systems.

Commits

v4.5.2 - November 13th, 2019

Bugfixes

  • fix: use String(field) in lookup when checking for "constructor" - d541378
  • test: add fluent API for testing Handlebars - c2ac79c

Compatibility notes:

  • no incompatibility are to be expected </tr></table> ... (truncated) </details> <details> <summary>Commits</summary>
  • c819c8b v4.5.3
  • 827c9d0 Update release notes
  • f7f05d7 fix: add "no-prototype-builtins" eslint-rule and fix all occurences
  • 1988878 fix: add more properties required to be enumerable
  • 886ba86 test/chore: add chai/expect and sinon to "runtime"-environment
  • 0817dad test: add sinon as global variable to eslint in the specs
  • 93516a0 test: add sinon.js for spies, deprecate current assertions
  • 93e284e chore: add chai and dirty-chai for better test assertions
  • c02b05f fix: use !== 0 instead of != 0
  • 8de121d v4.5.2
  • Additional commits viewable in compare view </details> <br />

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


<details> <summary>Dependabot commands and options</summary> <br />

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

</details>

+3 -3

0 comment

1 changed file

dependabot[bot]

pr closed time in 2 months

Pull request review commentnodejs/node

lib: API for interacting with source map cache

 class StringCharIterator {  * @param {SourceMapV3} payload  */ class SourceMap {+  #payload = null;   #reverseMappingsBySourceURL = [];   #mappings = [];   #sources = {};   #sourceContentByURL = {};    /**    * @constructor-   * @param {SourceMapV3} payload+   * @param {SourceMapV3} map

You renamed the docs here but not the actual parameter :]

bcoe

comment created time in 2 months

pull request commentnodejs/node

errors: annotate frames for prepareStackTrace()

@devsnek @joyeecheung - do either of you feel strongly enough to block? I noticed this currently has 2 approvals and I wanted to make sure that if you wish to object you do :]

bcoe

comment created time in 2 months

issue commentnodejs/node

Long stack traces in core

I am obviously a big +1 on anything that makes debugging async code easier :)

addaleax

comment created time in 2 months

issue commentnodejs/node

Long stack traces in core

I'm not sure what that would entail.

Also - do you mean for things other than async functions?

I was under the impression that we already do have long stack traces in core (for async functions) with --async-stack-traces

addaleax

comment created time in 2 months

issue commentnodejs/node

Nominating @GeoffreyBooth

+1 when I interacted with @GeoffreyBooth in the modules team he was helpful and also knew to argue his points and not give in without proper discussion. I would trust his judgment with our code and if he is up for the task I think he could make a good addition to the collaborators team.

MylesBorins

comment created time in 2 months

Pull request review commentnodejs/node

events: add EventEmitter.on to async iterate over events

 Value: `Symbol.for('nodejs.rejection')`  See how to write a custom [rejection handler][rejection]. +## events.on(emitter, eventName)+<!-- YAML+added: REPLACEME+-->++* `emitter` {EventEmitter}+* `eventName` {string|symbol} The name of the event being listened for+* Returns: {AsyncIterator} that iterates `eventName` events emitted by the `emitter`++```js+const { on, EventEmitter } = require('events');++(async () => {+  const ee = new EventEmitter();++  // Emit later on+  process.nextTick(() => {+    ee.emit('foo', 'bar');+    ee.emit('foo', 42);+  });++  for await (const event of on(ee, 'foo')) {+    // The execution of this inner block is synchronous and it+    // process one event at a time (even with await). Do not use+    // if parallel execution is required.
    // if concurrent execution is required.
mcollina

comment created time in 2 months

Pull request review commentnodejs/node

events: add EventEmitter.on to async iterate over events

 Value: `Symbol.for('nodejs.rejection')`  See how to write a custom [rejection handler][rejection]. +## events.on(emitter, eventName)+<!-- YAML+added: REPLACEME+-->++* `emitter` {EventEmitter}+* `eventName` {string|symbol} The name of the event being listened for+* Returns: {AsyncIterator} that iterates `eventName` events emitted by the `emitter`++```js+const { on, EventEmitter } = require('events');++(async () => {+  const ee = new EventEmitter();++  // Emit later on+  process.nextTick(() => {+    ee.emit('foo', 'bar');+    ee.emit('foo', 42);+  });++  for await (const event of on(ee, 'foo')) {+    // The execution of this inner block is synchronous and it+    // process one event at a time (even with await). Do not use
    // processes one event at a time (even with await). Do not use
mcollina

comment created time in 2 months

pull request commentnodejs/node

async-hooks: introduce async-storage API

We need @mscdex to unblock or to go to a vote I believe if we want to merge this.

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

events: add EventEmitter.on to async iterate over events

 function once(emitter, name) {     emitter.once(name, eventListener);   }); }++const AsyncIteratorPrototype = ObjectGetPrototypeOf(+  ObjectGetPrototypeOf(async function* () {}).prototype);++function createIterResult(value, done) {+  return { value, done };+}++function on(emitter, event) {+  const unconsumedEvents = [];+  const unconsumedPromises = [];+  let error = null;++  const iterator = ObjectSetPrototypeOf({+    next() {+      if (error) {+        return PromiseReject(error);+      }++      const value = unconsumedEvents.shift();+      if (value) {+        return PromiseResolve(createIterResult(value, false));+      }++      return new Promise(function(resolve, reject) {+        unconsumedPromises.push({ resolve, reject });+      });+    },++    return() {+      emitter.removeListener(event, eventHandler);+      emitter.removeListener('error', errorHandler);++      for (const promise of unconsumedPromises) {+        promise.resolve(createIterResult(undefined, true));+      }++      return PromiseResolve(createIterResult(undefined, true));+    },++    throw(err) {+      if (!err || !(err instanceof Error)) {+        throw new ERR_INVALID_ARG_TYPE('EventEmitter.AsyncIterator',+                                       'Error', err);+      }+      error = err;+      emitter.removeListener(event, eventHandler);+      emitter.removeListener('error', errorHandler);+    },++    [SymbolAsyncIterator]() {+      return this;+    }+  }, AsyncIteratorPrototype);++  emitter.on(event, eventHandler);+  emitter.on('error', errorHandler);++  return iterator;++  function eventHandler(...args) {+    const promise = unconsumedPromises.shift();+    if (promise) {+      promise.resolve(createIterResult(args, false));+    } else {+      unconsumedEvents.push(args);+    }+  }++  function errorHandler(err) {+    if (unconsumedPromises.length > 0) {+      for (const promise of unconsumedPromises) {+        promise.reject(err);+      }+    } else {+      emitter.removeListener(event, eventHandler);

After talking to @Raynos I believe we should do the async generator behavior

mcollina

comment created time in 2 months

Pull request review commentnodejs/node

repl: add reverse search

 function setupPreview(repl, contextSymbol, bufferSymbol, active) {   return { showPreview, clearPreview }; } +function setupReverseSearch(repl) {+  // Simple terminals can't use reverse search.+  if (process.env.TERM === 'dumb') {+    return { reverseSearch() { return false; } };+  }++  const alreadyMatched = new Set();+  const labels = {+    r: 'bck-i-search: ',+    s: 'fwd-i-search: '+  };+  let isInReverseSearch = false;+  let historyIndex = -1;+  let input = '';+  let cursor = -1;+  let dir = 'r';+  let lastMatch = -1;+  let lastCursor = -1;+  let promptPos;++  function next() {+    return historyIndex >= 0 && historyIndex < repl.history.length;+  }++  function isDirectionKey(keyName) {

I'm not a fan of this method mutating dir while called isDirectionKey. Would setDirectionKey or something similar make sense?

BridgeAR

comment created time in 2 months

Pull request review commentnodejs/node

repl: add reverse search

 function setupPreview(repl, contextSymbol, bufferSymbol, active) {   return { showPreview, clearPreview }; } +function setupReverseSearch(repl) {+  // Simple terminals can't use reverse search.+  if (process.env.TERM === 'dumb') {+    return { reverseSearch() { return false; } };+  }++  const alreadyMatched = new Set();+  const labels = {+    r: 'bck-i-search: ',+    s: 'fwd-i-search: '+  };+  let isInReverseSearch = false;+  let historyIndex = -1;+  let input = '';+  let cursor = -1;+  let dir = 'r';+  let lastMatch = -1;+  let lastCursor = -1;+  let promptPos;++  function next() {

hasNext instead of next maybe since this doesn't actually promote historyIndex

BridgeAR

comment created time in 2 months

Pull request review commentnodejs/node

repl: add reverse search

 function setupPreview(repl, contextSymbol, bufferSymbol, active) {   return { showPreview, clearPreview }; } +function setupReverseSearch(repl) {+  // Simple terminals can't use reverse search.+  if (process.env.TERM === 'dumb') {

Do we also want to consider "unknown" here in addition to "dumb", also, do we wan . to document this fact?

BridgeAR

comment created time in 2 months

issue commentpetkaantonov/bluebird

Using bluebird.couroutine for async generator via babel stores tons of error stack traces in closure

@petkaantonov wdyt? ^ This sounds rather reasonable.

antonellil

comment created time in 2 months

startedRaynos/pre-bundled

started time in 2 months

startedRaynos/npm-bin-deps

started time in 2 months

issue commentpetkaantonov/bluebird

map() with concurrency ignores elements order

Happy to debate and again, I would be happy to take the change if we can prove there is no performance regression.

ArtemInvisMaliuha

comment created time in 2 months

Pull request review commentnodejs/node

events: add EventEmitter.on to async iterate over events

 function once(emitter, name) {     emitter.once(name, eventListener);   }); }++const AsyncIteratorPrototype = ObjectGetPrototypeOf(+  ObjectGetPrototypeOf(async function* () {}).prototype);++function createIterResult(value, done) {+  return { value, done };+}++function on(emitter, event) {+  const unconsumedEvents = [];+  const unconsumedPromises = [];+  let error = null;++  const iterator = ObjectSetPrototypeOf({+    next() {+      if (error) {+        return Promise.reject(error);

Ah, just moving to primordials - got it

mcollina

comment created time in 2 months

issue commentpetkaantonov/bluebird

map() with concurrency ignores elements order

You can always split the data and the concurrency:

const ipAddresses = ['x.x.x.1', ..., 'x.x.x.255'];
const tickets = Array(ipAddresses.length).fill(); // just the tickets.
Promise.map(tickets, () => {
  const item = ipAddresses.shift();
  return process({item, index: ipAddresses.length });
}, { concurrency: whatever });

And then you pay the cost of shifting in your code (and not bluebird's)

ArtemInvisMaliuha

comment created time in 2 months

issue commentpetkaantonov/bluebird

map() with concurrency ignores elements order

Bluebird could do something different - the queue holds all the indexes that are being handled when mapping. We don't actually have to do that and we could instead increment a pointer as a form of deleting or do something else that's clever and doesn't require shifting the whole array around.

ArtemInvisMaliuha

comment created time in 2 months

issue commentpetkaantonov/bluebird

map() with concurrency ignores elements order

So how is this a bad thing?

Basically:

.pop() is fast, if you store an array (like V8) as a chunk of memory all it has to do is decrement an index (length) by 1 and return the value stored there. It's an O(1) operation.

.shift needs to move the whole array around every time. It's an O(n) operation.

ArtemInvisMaliuha

comment created time in 2 months

issue commentpetkaantonov/bluebird

Using bluebird.couroutine for async generator via babel stores tons of error stack traces in closure

Are you generating a lot of Promise.coroutines during runtime and retaining them?

You are expected to call Promise.coroutine on your methods (on the prototype) and then calling those methods - this leads to a low amount of captured stack traces (and low overhead).

You can use Promise.spawn for dynamic functions in the meantime (it's deprecated). If the use case is compelling enough we might un-deprecate it.

antonellil

comment created time in 2 months

Pull request review commentnodejs/node

events: add EventEmitter.on to async iterate over events

 function once(emitter, name) {     emitter.once(name, eventListener);   }); }++const AsyncIteratorPrototype = ObjectGetPrototypeOf(+  ObjectGetPrototypeOf(async function* () {}).prototype);++function createIterResult(value, done) {+  return { value, done };+}++function on(emitter, event) {+  const unconsumedEvents = [];+  const unconsumedPromises = [];+  let error = null;++  const iterator = ObjectSetPrototypeOf({+    next() {+      if (error) {+        return Promise.reject(error);

Why?

mcollina

comment created time in 2 months

issue commentpetkaantonov/bluebird

Using bluebird.couroutine for async generator via babel stores tons of error stack traces in closure

but wanted to check first the reasoning for generating the error stack at this point, and if it can be behind a flag or otherwise how to prevent this memory issue?

It's there as a debugging tool in order to provide long stack traces in production when an exception is thrown. You can disable it by building bluebird with stack traces false or setting Promise.config({ longStackTraces: false }).

antonellil

comment created time in 2 months

issue commentnodejs/node

Implement window.fetch into core

@gkatsanos we have discussed this in the May/June summit - here is what things were blocked on https://docs.google.com/document/d/1tn_-0S_FG_sla81wFohi8Sc8YI5PJiTopEzSA7UaLKM/edit?usp=sharing

thecodingdude

comment created time in 2 months

delete branch benjamingr/promise-fun

delete branch : patch-1

delete time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state between callbacks and promise+chains. It allows you to keep variables throughout the lifetime of a web request+or any other asynchronous duration. It is similar to what ThreadLocal storage is+ in other languages.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncContext.run((store) => {+      store.set(kReq, request);+      // some code+       someAsyncOperation((err, result) => {+        if (err) {+          log('ERR', err.message);+          // ... rest of the code+        }+      });+  });+})+.listen(8080);+```++### new AsyncContext()+* Returns: {AsyncContext}++Creates a new instance of `AsyncContext`. Until the `enter` method is called, it
Creates a new instance of `AsyncContext`. Storage is only provided inside a `run` method call.

Or something similar maybe?

vdeturckheim

comment created time in 2 months

pull request commentnodejs/node

async-hooks: introduce async-storage API

It would be good to get a profile measure of this.

I would assume pretty slow given async hooks have a ~2-3x performance penalty on promises IIRC (right?). I think a benchmark vs. a userland solution would be nice. If it is up for core to provide this (rather than vendor a blessed module) I think it needs justification.

If the process for doing so wasn't so hard I would recommend a userland model that Node blesses and maintains - but given our current processes I am more +1 on this than -1.

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext++This class is used to create contexts that can be used through the event loop.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_storage');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  const store = asyncContext.enter();+  store.set(kReq, request);+  // some code+   someAsyncOperation((err, result) => {+    if (err){+      log('ERR', err.message);+      // ... rest of the code+    }+  });+})+.listen(8080);+```++### new AsyncContext()++Creates a new instance of AsyncContext. Until the `enter` method is called, it+does not provide any storage features.++### asyncContext.enter()++Calling `asyncContext.enter()` will create a new asynchronous context.+This method returns a `Map` known as the store.++This store will be persistent through the following asynchronous calls.++### asyncContext.exit()+

Ah, the independence is achieved by having to hold an actual asyncStorage instance in order to get access to the data. Makes sense, this is different from other systems but I kind of like it.

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext++This class is used to create contexts that can be used through the event loop.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_storage');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  const store = asyncContext.enter();+  store.set(kReq, request);+  // some code+   someAsyncOperation((err, result) => {+    if (err){+      log('ERR', err.message);+      // ... rest of the code+    }+  });+})+.listen(8080);+```++### new AsyncContext()++Creates a new instance of AsyncContext. Until the `enter` method is called, it+does not provide any storage features.++### asyncContext.enter()++Calling `asyncContext.enter()` will create a new asynchronous context.+This method returns a `Map` known as the store.++This store will be persistent through the following asynchronous calls.++### asyncContext.exit()+

This thing (async context) is implemented in other languages and libraries as well right? What does C# do? What do zones do in JavaScript? What does CLS do?

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext++This class is used to create asynchronous state between callbacks and promise chain. It allows you to keep variables throughout the lifetime of a web request or any other asynchronous duration. It is similar to what ThreadLocal storage is in other languages.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncContext.run((store) => {+      store.set(kReq, request);+      // some code+       someAsyncOperation((err, result) => {+        if (err){+          log('ERR', err.message);+          // ... rest of the code+        }+      });+  });+})+.listen(8080);+```++### new AsyncContext()++Creates a new instance of AsyncContext. Until the `enter` method is called, it

I think in general these comments needs to be updated with:

  • <!-- YAML comments with REPLACEME for version added
  • arguments, for example: *callback{Function} etc.

You can see fs.md or other docs for how it's typically done and feel free to ask if you're not sure.

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext++This class is used to create asynchronous state between callbacks and promise chain. It allows you to keep variables throughout the lifetime of a web request or any other asynchronous duration. It is similar to what ThreadLocal storage is in other languages.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncContext.run((store) => {+      store.set(kReq, request);+      // some code+       someAsyncOperation((err, result) => {+        if (err){+          log('ERR', err.message);+          // ... rest of the code+        }+      });+  });+})+.listen(8080);+```++### new AsyncContext()++Creates a new instance of AsyncContext. Until the `enter` method is called, it+does not provide any storage features.++### asyncContext.run(callback)++Calling `asyncContext.enter(callback)` will create a new asynchronous context.

This is missing the argument documentation.

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext++This class is used to create contexts that can be used through the event loop.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_storage');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  const store = asyncContext.enter();+  store.set(kReq, request);+  // some code+   someAsyncOperation((err, result) => {+    if (err){+      log('ERR', err.message);+      // ... rest of the code+    }+  });+})+.listen(8080);+```++### new AsyncContext()++Creates a new instance of AsyncContext. Until the `enter` method is called, it+does not provide any storage features.++### asyncContext.enter()++Calling `asyncContext.enter()` will create a new asynchronous context.+This method returns a `Map` known as the store.++This store will be persistent through the following asynchronous calls.++### asyncContext.exit()+

Can one do this just by calling .create and get an empty map?

How does composing contexts work here?

vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext++This class is used to create asynchronous state between callbacks and promise chain. It allows you to keep variables throughout the lifetime of a web request or any other asynchronous duration. It is similar to what ThreadLocal storage is in other languages.++### Example++Let's build a logger that will always know the current HTTP request and use+it to display enhanced logs without needing to explicitly pass the current+HTTP request to it.++```js+const { AsyncContext } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncContext = new AsyncContext();++function log(...args) {+  const store = asyncContext.getStore();+  // Let's make sure the store exists and it contains a request+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // For instance, prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncContext.run((store) => {+      store.set(kReq, request);+      // some code+       someAsyncOperation((err, result) => {+        if (err){+          log('ERR', err.message);+          // ... rest of the code+        }+      });+  });+})+.listen(8080);+```++### new AsyncContext()++Creates a new instance of AsyncContext. Until the `enter` method is called, it
Creates a new instance of `AsyncContext`. Until the `enter` method is called, it
vdeturckheim

comment created time in 2 months

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +## Class: AsyncContext

I take it we have given up solving this at a TC39 level. That's a shame but also entirely understandable.

vdeturckheim

comment created time in 2 months

more