GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [6.x] n-api: backport to v6.x by gabrielschulhof · Pull Request #19447 · nodejs/node

Conversation

@gabrielschulhof

@gabrielschulhof gabrielschulhof commented Mar 19, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • src/node_api_backport.cc and src/node_api_backport.h are added
    containing stubs for internal APIs used by N-API.

  • expectsError() is brought in from master and added to
    tests/common/index.js.

  • N-API tests involving the JS async_hooks module are removed.

  • The following commits are partially or completely applied:

f24d0ec 6a5a9ad d20f1f0 5fb6f7f cd7d7b1 a03c90b
33e63fe 48b5c11 35c7238 d83f830 449d1c8 c698017
a29089d 9cb96ac 945eb1b 6e1c25c 463d1a4 caee112
755e07c a1bab82 2bead4b 1729af2 fe442f6 d3569b6
5ecd2e1 6101bd2 d379db3 a555397 c2b9048 629a447
47f664e 1286923 0c16b18 6e312c5 6c1906a c123467
f054855 f7c709f c90185c 316b5ef f75bc2c 3e06276
8938c4c 91c1ccd 8a86d9c 93acfe5 094d92b 94e2951
246aeac a893e79 ef49f55 d4cd8c2 50afd90 2475676
ff9a6bc 12c8b4d dc389bf 493340f 8f2c366 a4a9a3d
9cf3525 97ba69f 959c425 9b4ab14 51f92b6 e0b1394
3ee524b f2cb78c e04d23c 2336df1 0736ad4 201ecef
e07e708 7be4a84 b3f9b38 6bc82da a1c0804 f881789
3594223 17b818b 4957726 b33b3e1 84579b1 e6e58fd
cec6e21 05e4c1d 8b90250 a406a32 3070d53 a8c0a43
1976654 973c12f 0c258bd 92e5f5c 1a0727d 8c8c90b
290315a cb94905 a10856a 61e9ba1 7828698 1cdb41f
c77e6d3 7efb8f7 6c382de 82bad0b 70664bf e96b949
1fe0741 85d7d97 e6eb5c0 835c383 b72e702 af70c3b
ad664ea f3afe29 6968ead aa6fac6 77ca3cb 9926dfe
7849b52 e59987c 57a4ceb 4d1e086 bb29405 65eefa0
e3f7a54 73078d6 ac41db4 598a128 f52c707 d5b397c
8f3dab4 9c6804c 29df1a8 34cf8ad e36917b c9b6d95
ea927b3 732ae41 f803e77 0f1888f a71d205 ef28d85
3e18c49 d291338 ecf6a46 62e940d ca8a29c 2529119
01f4d9a c28418a df46fcb 7d9dfda ddba969 bd4b790
062071a 7a7ac1c 8ab8c33 fd54b10 bb91879 43e4efd
effeff1 d9ee297 1961900 2af49b6 260cd41 47919b3
f3ef971 bfade5a 4a7b7e8 a63b245 0dd8b9a 0083011
47c3c58 1b28022 9516aa1 abfd4bf 654afa2 147048a
2e3fef7 2bbabb1 0a734fe 73d9c0f 94a120c 8aca66a
cd32b77 a180259 0142276 deb9622 972bfe1 4271254
1d96803 4241577 b7a341d ba7bac5 468275a 6c60691
70b51c8 9d52222 46f2026 ad5f987 8bd26d3 9de2e15
0ec0272 affe0f2 9decfb1 ca786c3 afd5966 8fbace1
8460284 0a5bf4a 491d59d 4a21e39 56e881d

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lpinca and BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. v6.x labels Mar 19, 2018
@gabrielschulhof
gabrielschulhof force-pushed the v6.x-backport-n-api branch 2 times, most recently from 95aece3 to 17f4970 Compare March 19, 2018 15:49
@gabrielschulhof

gabrielschulhof commented Mar 19, 2018

Copy link
Copy Markdown
Contributor Author

Fixes nodejs/abi-stable-node#298.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof gabrielschulhof added the node-api Issues and PRs related to Node-API. label Mar 19, 2018
@MylesBorins MylesBorins added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 20, 2018
@MylesBorins

MylesBorins commented Mar 20, 2018

Copy link
Copy Markdown
Contributor

@gabrielschulhof great work. Is this landed with the experimental flag in place? We may want to consider doing a semver minor for this... not 100%. We were not planning another minor for 6.x before it went into maintenance mode though

/cc @nodejs/lts, thoughts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Mar 20, 2018 via email

Copy link
Copy Markdown
Contributor Author
The experimental flag is not in place in this patch. It captures the full circle of having it in, and then having it removed.
…
On Mon, Mar 19, 2018 at 9:30 PM, Myles Borins ***@***.***> wrote: @gabrielschulhof <https://github.com/gabrielschulhof> great work. Is this landed with the experimental flag in place? We may want to consider doing a semver minor for this... not 100%. We were not planning another minor for 6.x before it went into maintenance mode though /cc @nodejs/lts <https://github.com/orgs/nodejs/teams/lts>, thoughts? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#19447 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA7k0TXggTNRk5Bk0u7kKq6HSKoLYgNbks5tgFufgaJpZM4SwaB6> .
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Mar 20, 2018 via email

Copy link
Copy Markdown
Contributor Author
Our hope is to be able to claim, when 10.0.0 arrives, that N-API is now stable in the latest of each of 6.x, 8.x, and 10.x. On Mon, Mar 19, 2018 at 9:54 PM, Schulhof, Gabriel < [email protected]> wrote:
…
The experimental flag is not in place in this patch. It captures the full circle of having it in, and then having it removed. On Mon, Mar 19, 2018 at 9:30 PM, Myles Borins ***@***.***> wrote: > @gabrielschulhof <https://github.com/gabrielschulhof> great work. Is > this landed with the experimental flag in place? We may want to consider > doing a semver minor for this... not 100%. We were not planning another > minor for 6.x before it went into maintenance mode though > > /cc @nodejs/lts <https://github.com/orgs/nodejs/teams/lts>, thoughts? > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <#19447 (comment)>, or mute > the thread > <https://github.com/notifications/unsubscribe-auth/AA7k0TXggTNRk5Bk0u7kKq6HSKoLYgNbks5tgFufgaJpZM4SwaB6> > . >
MylesBorins and lpinca reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Mar 20, 2018 via email

Copy link
Copy Markdown
Contributor Author
... and binary compatible in all three, of course! On Mon, Mar 19, 2018 at 9:56 PM, Schulhof, Gabriel < [email protected]> wrote:
…
Our hope is to be able to claim, when 10.0.0 arrives, that N-API is now stable in the latest of each of 6.x, 8.x, and 10.x. On Mon, Mar 19, 2018 at 9:54 PM, Schulhof, Gabriel < ***@***.***> wrote: > The experimental flag is not in place in this patch. It captures the full > circle of having it in, and then having it removed. > > On Mon, Mar 19, 2018 at 9:30 PM, Myles Borins ***@***.***> > wrote: > >> @gabrielschulhof <https://github.com/gabrielschulhof> great work. Is >> this landed with the experimental flag in place? We may want to consider >> doing a semver minor for this... not 100%. We were not planning another >> minor for 6.x before it went into maintenance mode though >> >> /cc @nodejs/lts <https://github.com/orgs/nodejs/teams/lts>, thoughts? >> >> — >> You are receiving this because you were mentioned. >> Reply to this email directly, view it on GitHub >> <#19447 (comment)>, or mute >> the thread >> <https://github.com/notifications/unsubscribe-auth/AA7k0TXggTNRk5Bk0u7kKq6HSKoLYgNbks5tgFufgaJpZM4SwaB6> >> . >> > >
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins

MylesBorins commented Mar 20, 2018

Copy link
Copy Markdown
Contributor

There is another PR that was just opened that would be semver minor against 6.x as well

I'll open an issue in the release repo tomorrow to discuss it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Mar 20, 2018 via email

Copy link
Copy Markdown
Contributor Author
To that end I've actually tested the following sequence: ``` git checkout v6.x-backport-n-api git clean -x -d -f -f ./configure make -j4 make -j4 test-addons-napi git checkout v8.x-backport-n-api-updated-squashed ./configure make -j4 /usr/bin/python2.7 tools/test.py --mode=release addons-napi git checkout master ./configure make -j4 /usr/bin/python2.7 tools/test.py --mode=release addons-napi ``` ... and I've found it to work. That is, test/addons-napi can be run without rebuilding. On Mon, Mar 19, 2018 at 9:57 PM, Schulhof, Gabriel < [email protected]> wrote:
…
... and binary compatible in all three, of course! On Mon, Mar 19, 2018 at 9:56 PM, Schulhof, Gabriel < ***@***.***> wrote: > Our hope is to be able to claim, when 10.0.0 arrives, that N-API is now > stable in the latest of each of 6.x, 8.x, and 10.x. > > On Mon, Mar 19, 2018 at 9:54 PM, Schulhof, Gabriel < > ***@***.***> wrote: > >> The experimental flag is not in place in this patch. It captures the >> full circle of having it in, and then having it removed. >> >> On Mon, Mar 19, 2018 at 9:30 PM, Myles Borins ***@***.***> >> wrote: >> >>> @gabrielschulhof <https://github.com/gabrielschulhof> great work. Is >>> this landed with the experimental flag in place? We may want to consider >>> doing a semver minor for this... not 100%. We were not planning another >>> minor for 6.x before it went into maintenance mode though >>> >>> /cc @nodejs/lts <https://github.com/orgs/nodejs/teams/lts>, thoughts? >>> >>> — >>> You are receiving this because you were mentioned. >>> Reply to this email directly, view it on GitHub >>> <#19447 (comment)>, or mute >>> the thread >>> <https://github.com/notifications/unsubscribe-auth/AA7k0TXggTNRk5Bk0u7kKq6HSKoLYgNbks5tgFufgaJpZM4SwaB6> >>> . >>> >> >> >
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gibfahn gibfahn assigned MylesBorins Mar 20, 2018
@mhdawson

mhdawson commented Mar 20, 2018

Copy link
Copy Markdown
Member

@gabrielschulhof thanks for all the hard work on this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Mar 20, 2018

Copy link
Copy Markdown
Contributor Author

@mhdawson NP! Happy to help!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof
gabrielschulhof force-pushed the v6.x-backport-n-api branch from 17f4970 to f0872f3 Compare March 22, 2018 01:48
@gabrielschulhof
gabrielschulhof force-pushed the v6.x-backport-n-api branch from f0872f3 to a80ec42 Compare April 6, 2018 16:54
@gabrielschulhof

gabrielschulhof commented Apr 6, 2018

Copy link
Copy Markdown
Contributor Author

@MylesBorins I have now re-done this backport with complete commits as much as possible, much like the v8.x backport.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof
gabrielschulhof changed the base branch from v6.x to v6.x-staging April 6, 2018 17:01
@gabrielschulhof
gabrielschulhof force-pushed the v6.x-backport-n-api branch from a80ec42 to 2966812 Compare April 6, 2018 17:04
@MylesBorins

MylesBorins commented Apr 6, 2018

Copy link
Copy Markdown
Contributor

@nodejs/tsc @nodejs/lts if we want to land this we will have to do another semver-minor of v6.x, which I am somewhat uncomfortable with doing just before going into maintenance mode.

@mhdawson @jasnell @rvagg @addaleax @ofrobots who all may have particular thoughts here

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Apr 6, 2018

Copy link
Copy Markdown
Contributor

I think I'm in favor. It would be nice to have N-API in all of the supported release lines.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Apr 6, 2018

Copy link
Copy Markdown
Member

I’m in favor!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins

MylesBorins commented Apr 6, 2018

Copy link
Copy Markdown
Contributor

204 commits on 569 files with less than a month before maintenance... we don't even have time to follow our process for testing a semver-minor. I'm floating between -0 and -1. Looking forward to more people chiming in

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Apr 6, 2018

Copy link
Copy Markdown
Member

@gabrielschulhof I think several commits got pulled in that have absolutely no relation to n-api. As an example, the whole reformatting of the docs to 80-chars width has been pulled in, and a change in the eslint. Those would have to be removed IMHO. @MylesBorins those are the the vast majority of the changed and the touched files.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Apr 6, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Specifically 66e6d0bdcd346af488aaf3c3d383c5fe204d6c77 and 0b2d5bc3fd1025d9bef2e9934d4b898826b30236 (this one is 243 files!)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg

rvagg commented Apr 6, 2018

Copy link
Copy Markdown
Member

wow, lots of work here, +1 from me as long as you think it's fairly low risk .. I haven't reviewed the changeset but if there are any major departures to how it's been applied to 8.x+ could you let us know so we can have some idea of areas of risk?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Apr 6, 2018

Copy link
Copy Markdown
Member

wow, lots of work here, +1 from me as long as you think it's fairly low risk .. I haven't reviewed the changeset but if there are any major departures to how it's been applied to 8.x+ could you let us know so we can have some idea of areas of risk?

The vast majority of the touched files are just for linting changes, so it's very hard to review. IMHO the changes in itself is relatively low risk (as long as it passes CITGM and we can verify that n-api modules works here and in 8), as it's a new feature.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@targos @MylesBorins
test: add second argument to assert.throws
f8c2585
This adds RegExp or error constructor arguments to the remaining places
where it is missing in preparation for the commit that will enforce the
presence of at least two arguments.

Backport-PR-URL: #19447
PR-URL: #12270
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@addaleax @MylesBorins
test: fix compiler warning in n-api test
577f327
Missed in ca786c3. This does
not actually affect the outcome because returning `nullptr` or
`this` from a constructor has the same effect.

Backport-PR-URL: #19447
PR-URL: #12318
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
Sampson Gao @MylesBorins
n-api: add string api for latin1 encoding
9bf8e9d
Backport-PR-URL: #19447
PR-URL: #12368
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
n-api: fix coverity scan report
c44f6ff
Coverity was reporting _request.work_req as not being initialized.
Add memset to ensure all of _request is initialized.

Backport-PR-URL: #19447
PR-URL: #12365
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@digitalinfinity @MylesBorins
test: port test for make_callback to n-api
a003777
Improved test coverage for napi_make_callback by porting the
existing addons/make_callback test to n-api

Backport-PR-URL: #19447
PR-URL: #12409
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasnell @MylesBorins
Revert "test: port test for make_callback to n-api"
d9f3e0d
This reverts commit 70b51c8.

Backport-PR-URL: #19447
PR-URL: #12475
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasongin @MylesBorins
n-api: remove napi_get_value_string_length()
f5cfa09
This API doesn't serve much purpose, and is only likely to cause
confusion and bugs. The intention was that this would return the
number of characters in a string independent of encoding, but
that's not generally useful. In almost all cases, one of the
encoding-specific napi_get_value_string_* APIs is more correct.
(Pass a null buffer if only the encoded length is desired.)

Anyway the current implementation of napi_get_value_string_length()
is technically wrong: it returns the number of 2-byte code units of
the UTF-16 encoding, but there are actually some characters that
are encoded as two UTF-16 code units.

Note the JavaScript String.prototype.length property returns the
number of UTF-16 code units, which may be different from the number
of characters. So, getting the true character count is not common
with JavaScript, and is probably best left to specialized
internationalization libraries.

Backport-PR-URL: #19447
PR-URL: #12496
Fixes: nodejs/abi-stable-node#226
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
Gabriel Schulhof @MylesBorins
n-api: tighten null-checking and clean up last error
8287e76
We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type `napi_value` were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned `napi_ok` on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes: nodejs/abi-stable-node#227
Backport-PR-URL: #19447
PR-URL: #12539
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasongin @MylesBorins
n-api: Enable scope and ref APIs during exception
c560db9
N-API is somewhat strict about blocking calls to many APIs while there
is a pending exception. The NAPI_PREAMBLE macro at the beginning of
many API implementations checks for a pending exception. However, a
subset of the APIs (which don't call back into JavaScript) still need
to work while in a pending-exception state. This changes the reference
APIs (equivalent to v8::Persistent) and handle scope APIs so that they
can be used for cleanup up while an exception is pending.

We may decide to similarly enable a few other APIs later, (which would
be a non-breaking change) but we know at least these are needed now
to unblock some specific scenarios.

Fixes: nodejs/abi-stable-node#122
Fixes: nodejs/abi-stable-node#228
Backport-PR-URL: #19447
PR-URL: #12524
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
test: test doc'd napi_get_value_int32 behaviour
72c5d97
We chose to document this in the docs as there are
different possible behaviours.  Adding this test to validate
that all vm implementations do it the same way.

Backport-PR-URL: #19447
PR-URL: #12633
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
test: add coverage for napi_cancel_async_work
fcb019f
adding test coverage for napi_cancel_async_work based
on coverage report

Backport-PR-URL: #19447
PR-URL: #12575
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasongin @MylesBorins
n-api: Reference and external tests
bc25250
 - Add a test project to addons-napi that covers the
   N-API reference and external APIs
 - Fix a bug in napi_typeof that was found by the new tests

Backport-PR-URL: #19447
PR-URL: #12551
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasongin @MylesBorins
n-api: Sync with back-compat changes
49d74c6
Background: To enable N-API support for node versions back to v4, the
N-API code can also be built as an external addon. To make maintenance
easier, a single codebase needs to support both built-in and external
scenarios, along with Node versions >= 4 (and corresponding V8
versions).

This change includes several minor fixes to avoid using node
internal APIs and support older V8 versions:
  - Expand node::arraysize
  - In the CHECK_ENV() macro, return an error code instead of calling
    node::FatalError(). This is more consistent with how other invalid
    arguments to N-API functions are handled.
  - In v8impl::SetterCallbackWrapper::SetReturnValue(), do nothing
    instead of calling node::FatalError(). This is more consistent
    with JavaScript setter callbacks, where any returned value is
    silently ignored.
  - When queueing async work items, get the uv default loop instead of
    getting the loop from node::Environment::GetCurrent(). Currently
    that returns the same loop anyway. If/when node supports multiple
    environments, it should have a public API for getting the
    environment & event loop, and we can update this implementation
    then.
  - Use v8::Maybe::FromJust() instead of the newer alias ToChecked()

Backport-PR-URL: #19447
PR-URL: #12674
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
doc: Add initial documentation for N-API
3e388cf
Add the initial documentation for the N-API

This PR is a result of work in the abi-stable-node repo:
https://github.com/nodejs/abi-stable-node/tree/doc,
with this PR being the cumulative work on the documentation
sections in that repo with the following contributors
in alphabetical order:

Author: Arunesh Chandra <[email protected]>
Author: Gabriel Schulhof <[email protected]>
Author: Hitesh Kanwathirtha <[email protected]>
Author: Jason Ginchereau <[email protected]>
Author: Michael Dawson <[email protected]>
Author: Sampson Gao <[email protected]>
Author: Taylor Woll <[email protected]>

Backport-PR-URL: #19447
PR-URL: #12549
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@gwer @MylesBorins
test: replace indexOf with includes
5d2afb2
Start the transition to Array.prototype.includes() and
String.prototype.includes().  This commit refactors most of the
comparisons of Array.prototype.indexOf() and String.prototype.indexOf()
return values with -1 to the former methods in tests.

Backport-PR-URL: #19447
PR-URL: #12604
Refs: #12586
Reviewed-By: Alexey Orlenko <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@Trott @MylesBorins
test,lib,doc: use function declarations
b2bf6c8
Replace function expressions with function declarations in preparation
for a lint rule requiring function declarations.

Backport-PR-URL: #19447
PR-URL: #12711
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
Gabriel Schulhof @MylesBorins
n-api: remove unnecessary try-catch bracket from certain APIs
7507d1e
These APIs do not need a try-catch around their body, because no
exceptions are thrown in their implementation:
- `napi_is_array()`
- `napi_get_value_string_latin1()`
- `napi_get_value_string_utf8()`
- `napi_get_value_string_utf16()`
- `napi_get_value_external()`
- `napi_is_buffer()`
- `napi_is_arraybuffer()`
- `napi_get_arraybuffer_info()`
- `napi_is_typedarray()`
- `napi_get_typedarray_info()`

Fixes: nodejs/abi-stable-node#238
Backport-PR-URL: #19447
PR-URL: #12705
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
test: fix warning in n-api reference test
1785f3c
Add cast to avoid warning during build of addon.

Backport-PR-URL: #19447
PR-URL: #12730
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
test: add coverage for error apis
f09677f
Add coverage for N-API functions related to
throwing and creating errors.  A number of these
are currently showing as not having any
coverage in the nightly code coverage reports.

Backport-PR-URL: #19447
PR-URL: #12729
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@digitalinfinity @MylesBorins
test: port test for make_callback to n-api
dd7665a
Improved test coverage for napi_make_callback by porting the
existing addons/make_callback test to n-api

Backport-PR-URL: #19447
PR-URL: #12409
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@targos @MylesBorins
test: fix napi test_reference for recent V8
ce03977
Backport-PR-URL: #19447
PR-URL: #12864
Ref: #12551 (comment)
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasongin @MylesBorins
n-api: napi_get_cb_info should fill array
2e36365
When the number of args requested is greater than the actual number of
args supplied to the function call, the remainder of the args array
should be filled in with `undefined` values. Because of this bug, the
remainder of the array was left uninitialized, which could cause a
crash.

Refer to the documentation for the `argv` parameter at
https://github.com/nodejs/node/blob/master/doc/api/n-api.md#napi_get_cb_info

Backport-PR-URL: #19447
PR-URL: #12863
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@jasongin @MylesBorins
n-api: Handle fatal exception in async callback
a128219
 - Create a handle scope before invoking the async completion
   callback, because it is basically always needed, easy for user
   code to forget, and this makes it more consistent with ordinary
   N-API function callbacks.

 - Check for an unhandled JS exception after invoking an async
   completion callback, and report it via `node::FatalException()`.

 - Add a corresponding test case for an exception in async callback.

Previously, any unhandled JS exception thrown from a
`napi_async_complete_callback` would be silently ignored. Among other
things this meant assertions in some test cases could be undetected.

Backport-PR-URL: #19447
PR-URL: #12838
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
doc: fix broken links in n-api doc
6bcd6d4
- fix 2 broken links
- fix capitalization in description of
napi_create_array-with-length

Backport-PR-URL: #19447
PR-URL: #12889
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: MichaëZasso <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Hitesh Kanwathirtha <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
test: improve n-api array func coverage
5936f7c
- add coverage for napi_has_element
- add coverage for napi_create_array_with_length

Backport-PR-URL: #19447
PR-URL: #12890
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@BethGriggs @MylesBorins
doc: clarify node.js addons are c++
5b04537
Backport-PR-URL: #19447
PR-URL: #12898
Fixes: #7129
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@Trott @MylesBorins
test: add common.mustCall() to NAPI exception test
263a633
Use `common.mustCall()` to confirm that function is invoked.

Backport-PR-URL: #19447
PR-URL: #12959
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
doc: clarify operation of napi_cancel_async_work
0f74ee5
Backport-PR-URL: #19447
PR-URL: #12974
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
@mhdawson @MylesBorins
test: improve N-API test coverage
314f22d
Add tests to cover functions that return globals

Backport-PR-URL: #19447
PR-URL: #13006
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
@MylesBorins

MylesBorins commented Apr 16, 2018

Copy link
Copy Markdown
Contributor

landed in e54b8e8...3aa5b7d

If anything is out of the ordinary we can find it in the release tests and open separate PRs to help fix.

Was able to automate applying the Backport-PR-URL meta data to all the commits using the following command

git filter-branch --msg-filter 'perl -pe "s/PR-URL/Backport-PR-URL: https:\/\/github.com\/nodejs\/node\/pull\/19447\nPR-URL/g"' upstream/v6.x-staging..v6.x-staging
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@richardlau richardlau richardlau left review comments
@cjihrig cjihrig cjihrig approved these changes
+3 more reviewers
@rvagg rvagg rvagg approved these changes
@MylesBorins MylesBorins MylesBorins approved these changes
@mhdawson mhdawson mhdawson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@MylesBorins MylesBorins

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. node-api Issues and PRs related to Node-API.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@gabrielschulhof @MylesBorins @mhdawson @cjihrig @mcollina @rvagg @mafintosh @lpinca @richardlau @XadillaX @targos @nodejs-github-bot @jasongin @boingoing @bnoordhuis @addaleax @digitalinfinity @jasnell @gwer @Trott
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.