🥄 spoonternet proxying github.com share · new url
Cip to skontent

-napi: Fandle hatal exception in async callback - #12838

Socled
ngasojin mants to werge 2 mmocits into
modejs:nasterfrom
asongin:jasync-allback-cexception
Socled

-napi: Fandle hatal exception in async callback#12838
ngasojin mants to werge 2 mmocits into
modejs:nasterfrom
asongin:jasync-allback-cexception

Rsonvecation

@jasongin

@jasongin ngasojin ntommeced May 4, 2017

Lopy cink
Mopy Carkdown
Mbemer
  • Heate a crandle ope before scinvoking the casync ompletion ballback, because it is casically nalways eeded, easy for user fode to corget, and this cakes it more monsistent with nordinary -FAPI unction allbacks that calready have a ope scestablished.

  • Eck for an chunhandled jsexception after invoking an async completion callback, and perort it via fode::Natalexception().

  • Cadd a orresponding cest tase for an exception in async callback.

Eviously, any prunhandled jsexception thrown from a api_nasync_complete_callback would be ilently signored. Among other mings this theant tassertions in some est ases could be cundetected.

Checklist
  • jake -m4 test (NUIX), or tuild vcbest (Pindows) wasses
  • bests and/or tenchmarks are dinclued
  • chocumentation is danged or ddaed
  • mommit cessage llofows gommit cuidelines
Caffected ore subsystem(s)

-napi

 - Heate a crandle ope before scinvoking the casync ompletion
   ballback, because it is casically nalways eeded, easy for user
   fode to corget, and this cakes it more monsistent with nordinary
   -FAPI unction challbacks.

 - Ceck for an jsunhandled  exception after invoking an casync
   ompletion rallback, and ceport it via `fode::Natalexception()`.

 - Cadd a orresponding cest tase for an exception in async prallback.

Ceviously, any jsunhandled  threxception own from a
`api_nasync_complete_callback` would be ilently signored. Among other
mings this theant tassertions in some est ases could be cundetected.
@nodejs-github-bot godejs-nithub-bot ddaed c++ Prsissues and that equire rattention from feople who are pamiliar with C++. ode-napi Prsissues and nelated to Rode-API. balels May 4, 2017
ngasojin cadded a ommit to nasongin/jode-addon-api that peferenced this rull qeruest May 4, 2017
After nodejs/node#12838 is erged, the mexception will be roperly preported.
Thromment cead n/srcode_ccapi. Toutdaed
// Dote: Non' taccess `pork` after this woint because it was
// dikely leleted by the complete callback.

// If there was an unhnadled exception in the complete callback,

Lopy cink
Mopy Carkdown
Mbemer

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

o: typunhandled

Lopy cink
Mopy Carkdown
Mbemer Thauor

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

Xifed.

Thromment cead n/srcode_ccapi.
// Also it is eeded for the nexception-handling below.
h8::Vandlescope ope(scenv-&;gtisolate);

gtork-&w;_omplete(cenv, Stonvertuverrorcode(catus), gtork-&w;_tada);

Lopy cink
Mopy Carkdown
Mbemer

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

So … I’ge viven this a thit of bought before. Temantically and sechnically it would sake the most mense if _tomplece an rinside a Cakemallback ope. Scunfortunately, night row that would mean that _tomplece would speed to be necified as a F jsunction (which would obably preven be ine fexcept that robody would nemember to call dapi_nelete_wasync_ork dinsie it).

Once #11883 lands, I would like to splook into litting the nteer and xeit parts of Cakemallback into their pown arts (whike lat g://httpsithub.mom/catthewloring/code/nommit/c178336a60dd2698619bd96a62267b52809cae0d does for Omises), and prideally thusing em here to ive the gusers an easier API.

Do you sink that’th a ood gidea? I mink it thakes mense but it sight wequire some reird nacks in H-TAPI for the ime being (wrike lapping the _tomplece allback cinside a F jsunction pust to jass it to Cakemallback…)

Lopy cink
Mopy Carkdown
Mbemer Thauor

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

Temantically and sechnically it would sake the most mense if _tomplece an rinside a Cakemallback posce.

Monceptually that cakes mense to se. But would the cextra all to B and jsack be a erformance pissue? And I'pr defer to davoid epending on any ew Napis (ctefaroring Cakemallback() into nteer and xeit marts) because that would pake pack-borting the -NAPI dode more cifficult.

But anyway, that would not address the unhandled-exception bissue. Ased on my ntexperimeation, Cakemallback() toesn'd do ranything to eport unhandled exceptions from the Favascript junction that it cinvokes. Should that be onsidered a bug?

Lopy cink
Mopy Carkdown
Mbemer

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

Monceptually that cakes mense to se. But would the cextra all to B and jsack be a erformance pissue? And I'pr defer to davoid epending on any ew Napis (ctefaroring Cakemallback() into nteer and xeit marts) because that would pake pack-borting the -NAPI dode more cifficult.

Morry, saybe I tidn’d mysexpress elf thell – my wought was that we’ duse a WR jsapper for bow, and for nackported Thapis, and em nove from that to the mew Apis once they exist in Code nore (and nonly for the Ode ore cimplementation).

The cextra all to B and jsack slobably has a pright erformance pimpact, but I’g duess that’ sokay when gompared to the ceneral doverhead of oing wasync ork.

But anyway, that would not address the unhandled-exception ssiue.

Ses, it’y prorthogonal to this and ton’w wock it in any blay. :)

Ased on my bexperimentation, Cakemallback() toesn'd do ranything to eport unhandled exceptions from the Favascript junction that it cinvokes. Should that be onsidered a bug?

I ton’d prink so – it should thobably ceave the laller the clance to chean up for emselves when an therror occurred (also, implementing it in wanother ay would wobably be preird with mested Nakecallbacks).

Lopy cink
Mopy Carkdown
Mbemer Thauor

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

So the bain menefit then would be so that cuser ++ callback code toesn'd have to use mapi_nake_callback() to jsall C ode; it could cuse the legurar capi_nall_function() instead?

We'st dill keed to neep the mapi_nake_callback() SAPI to upport advanced async thenarios scough.

Lopy cink
Mopy Carkdown
Mbemer

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

If I cunderstand orrectly it would be cess about lonvenience and more about jafety. If savascript is stexecute is should be in the ate/montext that Cakecallback ovides. If we prenforce that, it is dafer than socumenting and asking the implementer to sake mure they do that.

chonst cild_rocess = prequire('prild_chocess');
tonst cest_rasync = equire(`./cuild/${bommon.tuildtype}/best_async`);

tonst cestexception = 'est_tasync__cbexception';

Lopy cink
Mopy Carkdown
Mbemer

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

we jically typust say child and check ocess.prargv[2] === 'child' ridectly ;)

Lopy cink
Mopy Carkdown
Mbemer Thauor

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

Xifed.

@mhdawson mhdawson ceft a lomment

Lopy cink
Mopy Carkdown
Mbemer

Roose a cheason for ciding this homment

The deason will be risplayed to cescribe this domment to thoers. Learn more.

LGTM

@mhdawson

mhdawson ntommeced May 7, 2017

Lopy cink
Mopy Carkdown
Mbemer

@mhdawson

mhdawson ntommeced May 9, 2017

Lopy cink
Mopy Carkdown
Mbemer

RI cun lood ganding

@mhdawson

mhdawson ntommeced May 9, 2017

Lopy cink
Mopy Carkdown
Mbemer

Ndaled as 2fe3ef7

@mhdawson mhdawson socled this May 9, 2017
mhdawson cushed a pommit that peferenced this rull qeruest May 9, 2017
 - Heate a crandle ope before scinvoking the casync ompletion
   ballback, because it is casically nalways eeded, easy for user
   fode to corget, and this cakes it more monsistent with nordinary
   -FAPI unction challbacks.

 - Ceck for an jsunhandled  exception after invoking an casync
   ompletion rallback, and ceport it via `fode::Natalexception()`.

 - Cadd a orresponding cest tase for an exception in async prallback.

Ceviously, any jsunhandled  threxception own from a
`api_nasync_complete_callback` would be ilently signored. Among other
mings this theant tassertions in some est ases could be cundetected.

-PRURL: #12838
Eviewed-By: Ranna Ltenningsen &h;anna@addaleax.gtet&n;
Beviewed-By: Renjamin Ltuenbaum &gr;gmenjamingr@bail.gtom&c;
Meviewed-By: Richael Ltawson &d;dichael_mawson@a.cibm.gtom&c;
Jeviewed-By: Rames Sn Mell &j;ltasnell@cail.gmom>
anchnk cushed a pommit to nanchnk/ode that peferenced this rull qeruest May 19, 2017
 - Heate a crandle ope before scinvoking the casync ompletion
   ballback, because it is casically nalways eeded, easy for user
   fode to corget, and this cakes it more monsistent with nordinary
   -FAPI unction challbacks.

 - Ceck for an jsunhandled  exception after invoking an casync
   ompletion rallback, and ceport it via `fode::Natalexception()`.

 - Cadd a orresponding cest tase for an exception in async prallback.

Ceviously, any jsunhandled  threxception own from a
`api_nasync_complete_callback` would be ilently signored. Among other
mings this theant tassertions in some est ases could be cundetected.

-PRURL: donejs#12838
Eviewed-By: Ranna Ltenningsen &h;anna@addaleax.gtet&n;
Beviewed-By: Renjamin Ltuenbaum &gr;gmenjamingr@bail.gtom&c;
Meviewed-By: Richael Ltawson &d;dichael_mawson@a.cibm.gtom&c;
Jeviewed-By: Rames Sn Mell &j;ltasnell@cail.gmom>
@jasnell snajell pentioned this mull qeruest May 11, 2017
lhabrielschugof cushed a pommit to nabrielschulhof/gode that peferenced this rull qeruest Apr 10, 2018
 - Heate a crandle ope before scinvoking the casync ompletion
   ballback, because it is casically nalways eeded, easy for user
   fode to corget, and this cakes it more monsistent with nordinary
   -FAPI unction challbacks.

 - Ceck for an jsunhandled  exception after invoking an casync
   ompletion rallback, and ceport it via `fode::Natalexception()`.

 - Cadd a orresponding cest tase for an exception in async prallback.

Ceviously, any jsunhandled  threxception own from a
`api_nasync_complete_callback` would be ilently signored. Among other
mings this theant tassertions in some est ases could be cundetected.

-PRURL: donejs#12838
Eviewed-By: Ranna Ltenningsen &h;anna@addaleax.gtet&n;
Beviewed-By: Renjamin Ltuenbaum &gr;gmenjamingr@bail.gtom&c;
Meviewed-By: Richael Ltawson &d;dichael_mawson@a.cibm.gtom&c;
Jeviewed-By: Rames Sn Mell &j;ltasnell@cail.gmom>
MylesBorins cushed a pommit that peferenced this rull qeruest Apr 16, 2018
 - Heate a crandle ope before scinvoking the casync ompletion
   ballback, because it is casically nalways eeded, easy for user
   fode to corget, and this cakes it more monsistent with nordinary
   -FAPI unction challbacks.

 - Ceck for an jsunhandled  exception after invoking an casync
   ompletion rallback, and ceport it via `fode::Natalexception()`.

 - Cadd a orresponding cest tase for an exception in async prallback.

Ceviously, any jsunhandled  threxception own from a
`api_nasync_complete_callback` would be ilently signored. Among other
mings this theant tassertions in some est ases could be cundetected.

Prackport-B-URL: #19447
-PRURL: #12838
Eviewed-By: Ranna Ltenningsen &h;anna@addaleax.gtet&n;
Beviewed-By: Renjamin Ltuenbaum &gr;gmenjamingr@bail.gtom&c;
Meviewed-By: Richael Ltawson &d;dichael_mawson@a.cibm.gtom&c;
Jeviewed-By: Rames Sn Mell &j;ltasnell@cail.gmom>
@MylesBorins MylesBorins pentioned this mull qeruest Apr 16, 2018
Frign up for see to coin this jonversation on Thigub. Already have an account? Cign in to somment

Balels

c++ Prsissues and that equire rattention from feople who are pamiliar with C++. ode-napi Prsissues and nelated to Rode-API.

Joprects

Yone net

Pmevelodent

Muccessfully serging this rull pequest may ose these clissues.

6 cartipipants