93 Commits
Author SHA1 Message Date
Kenton Varda 1609fa1155 Merge branch 'node4' of github.com:kentonv/node-capnp into node4 2017-09-30 12:05:53 -07:00
Kenton Varda f575e4013c Add the ability to listen on a unix socket delivering connections via SCM_RIGHTS. 2017-09-30 12:05:30 -07:00
Kenton Varda 6525163b1b Update for recent KJ changes. Fixes #36. 2017-09-30 12:04:57 -07:00
Kenton Varda 7afd129314 Merge pull request #31 from dwrensha/capnp-node-is-missing
Fix error message: 'capnp.node.node' -> 'capnp.node'
2017-09-30 12:03:17 -07:00
Kenton Varda f2bfd6f95f Release 0.2.0 which supports node 4+. 2017-09-19 09:25:56 -07:00
Kenton Varda 888f772ef3 Fix several v8 usage bugs that could be causing our memory leaks.
- You can't just call SetWeak() on a handle and then let the handle go out-of-scope. You have to Reset() it when the weak callback is called. Honestly unsure why this doesn't crash.
- The weak handle should have MarkIndependent() called on it, otherwise v8 is less aggressive about GCing it.
- OwnHandle's move semantics were broken. They created a copy (which actually creates a new v8 persistent handle), but then zero'd the original (which means it would never be cleaned up by v8). V8 provides a nice `Global` type which has the semantics we always wanted, so use that.
2017-04-29 15:46:07 -07:00
Kenton Varda fbdb9959a9 Revert "Work around apparent memory leak in Node?"
After deploying this change, the frequency of production problems seems to have increased rather than decreased. I don't know if this change is the reason for the increase, but since it did not accomplish its sole goal of decreasing the problem rate, I'm reverting it.

This reverts commit 8497d70320.
2017-03-01 14:20:44 -08:00
Kenton Varda 816cbc38e0 Add a chacha20() function for Sandstorm's use, and add #ifdefs so that Sandstorm-private code isn't included in non-Sandstorm builds. 2017-02-16 20:06:05 -08:00
Kenton Varda 8497d70320 Work around apparent memory leak in Node? 2017-02-14 02:51:54 -08:00
Kenton Varda 4f251bedc6 Merge pull request #32 from kentonv/powerbox-query
Implement Sandstorm powerbox query matching algorithm as a library function.
2016-12-07 23:03:56 -08:00
Kenton Varda 8dbc7e700d Update test per @dwrensha's review comments. 2016-12-05 10:43:52 -08:00
Kenton Varda 1d0caa3f30 Support 'null' appearing in pointer lists. 2016-12-05 10:43:27 -08:00
Kenton Varda 302ae1779f Implement Sandstorm powerbox query matching algorithm as a library function.
Algorithm documented here: https://github.com/sandstorm-io/sandstorm/blob/master/src/sandstorm/powerbox.capnp#L115

Although this is Sandstorm-specific, I'm putting it into node-capnp for convenience: this needs to be implemented in C++, and it would be surprisingly difficult to create a second Node module that shares the Cap'n Proto library with capnp.node.
2016-12-04 16:58:10 -08:00
Kenton Varda 8e001b1ff1 Update for change to wrapConnectingSocketFd() signature. 2016-11-30 18:34:06 -08:00
Kenton Varda 492b1c9905 Fix closeAll(). 2016-11-12 13:20:00 -08:00
David Renshaw dd23d9bc5c Fix error message: 'capnp.node.node' -> 'capnp.node' 2016-11-05 19:23:09 -04:00
Kenton Varda 74958750f1 Add temporary code to count local capability types and support dumping them to stderr periodically. 2016-11-03 15:33:07 -07:00
Kenton Varda 05d868bc8f Do type checking / unwrapping the right way.
GetAlignedPoniterFromInternalField() can crash if the internal field is not a pointer, so we can't use this trick of checking if the field contains a pointer to the type's type_info.

The correct thing to do is use FunctionTemplate::HasInstance() to type-check the value. To do that, we of course have to have a reference to the FunctionTemplate already. To make this lookup fast, I used template-static-singletons.
2016-08-08 19:55:52 -07:00
Kenton Varda f48e50e7ff Don't download/install ES6 Promise polyfill anymore. 2016-08-08 18:55:05 -07:00
Kenton Varda 674090dba2 Silence some warnings originating in macros. 2016-08-08 18:54:44 -07:00
Kenton Varda 2b241848f5 Fix RPC callbacks using node::MakeCallback(). 2016-08-08 18:33:08 -07:00
Kenton Varda 4f2ee9bb8f Fix random crashes during GC.
This switches from the (apparently deprecated) WeakCallbackData-based SetWeak() to the newer WeakCallbackInfo-based one.

I have no fucking idea what the difference is, or what the WeakCallbackType enum is supposed to mean, or why it didn't work before. There is no documentation. There are various pages around the internet that make reference to this API but no comprehensive explanation anywhere as to the details. You're supposed to just know, or something.
2016-07-04 02:32:48 -07:00
Kenton Varda 8d57b61bba Promise capabilities take ownership of the capability to which they resolve.
Make sure that the node-level capability is replaced with one that will throw an exception from calls, rather than segfault on null pointer.
2016-07-03 22:13:04 -07:00
Kenton Varda 0c60f1f777 Support "flat" encoding, and "packed-flat" too. 2016-07-03 22:09:33 -07:00
Kenton Varda e3ce43e2be Include Javascript stack when converting to KJ exception. 2016-07-03 22:09:33 -07:00
Drew Fisher f7066436e9 Make the overhead computation look less like it has an integer underflow 2016-07-03 21:58:04 -07:00
Drew Fisher 533aa8043d Compute a tighter upper bound on the buffer needed for packed encoding 2016-07-03 21:56:10 -07:00
Drew Fisher 22a56c1607 Add tests for packed encoding/decoding. 2016-07-03 21:55:28 -07:00
Drew Fisher 7965ca80f5 Add support for serializing structures to packed Cap'n Proto encoding 2016-07-03 21:55:13 -07:00
Drew Fisher 2bdf71bbe2 Add support for parsing structures in Cap'n Proto's packed encoding 2016-07-03 21:49:19 -07:00
Kenton Varda 3d5d0c9d38 Update package.json to reflect the node API chanage. (I'm not actually sure if this works with 0.12, but it definitely doesn't work with 0.10 anymore.) 2016-02-15 19:11:14 -08:00
Kenton Varda 4128f687a8 Expose expectedSizeFromPrefix to node. 2016-02-15 19:05:43 -08:00
Kenton Varda eba8a33e66 Port to Node 4. 2016-02-14 23:33:53 -08:00
Kenton Varda 10e269d298 Void values are normally represented as 'null', so ignoring 'null' fields is wrong. 2016-02-09 18:41:47 -08:00
Kenton Varda 55d9a51855 Treat closed capability as disconnected.
This seems correct, and works around a bug in Sandstorm where a capability shared between multiple components is sometimes closed by one of them. This isn't the best way to fix the bug, but the real fix will require some refactoring.
2015-11-10 09:57:24 -08:00
Kenton Varda 753c11b038 Fix typo in previous commit. 2015-10-05 22:52:48 -07:00
Kenton Varda 5266df2ac6 Add some logging code to attempt to track down the event-loop-deadlocking bug, which apprently isn't fixed.
This change might inadvertently fix the problem, if it related to doRun() receiving a non-zero status.
2015-10-05 22:06:16 -07:00
Kenton Varda db34d99401 Properly close UV handles.
It turns out that you need to call uv_close() on all handles, but the libuv documentation does a remarkably good job of hiding this fact by not discussing it in any intros nor showing it in any examples.

In particular, UvEventPort was repeatedly re-initializing a timer handle over an existing handle that had been stopped but not closed (I had assumed "stop" also cleaned up).

In practice, the effect of this problems seems to be that on very rare occasion, the KJ<->UV glue will stop operating, such that the KJ event loop no longer dispatches any events. The problem only seems to occur on heavily-loaded servers and even then is rare. Possibly memory was being leaked as well, but if so, not very much.

(Actually, as of now I am not certain that this change fixes that problem, but I am certain that the code was wrong before this change.)
2015-09-29 12:38:02 -07:00
Kenton Varda c5207b697b Merge pull request #23 from jparyani/set-anypointer-with-cap
Allow setting AnyPointer fields with a capability
2015-06-12 16:19:13 -07:00
Jason Paryani 38c2366d79 Handle local caps properly when converting from AnyPointer 2015-06-12 15:50:27 -07:00
Jason Paryani ad69dc7bd8 Allow setting AnyPointer fields with a capability
This is blocked on https://github.com/sandstorm-io/capnproto/pull/214
2015-06-10 16:06:56 -07:00
Kenton Varda 8ab80bdf4c Merge pull request #21 from dwrensha/param-list
Fix off-by-one bug for methods with non-inline param list.
2015-06-05 14:29:12 -07:00
David Renshaw 3ef506cd94 Fix off-by-one bug for methods with non-inline param list. 2015-06-05 11:14:30 -04:00
Kenton Varda f8b1741b7e Merge pull request #20 from jparyani/fix-error-type
Rename error.type to kjType
2015-06-04 16:07:45 -07:00
Jason Paryani f74f71a580 Also rename type->kjType for converting from js exceptions 2015-06-04 15:49:07 -07:00
Jason Paryani 0e4602fd8c Rename error.type to kjType
This a workaround due to a v8 bug:
https://code.google.com/p/v8/issues/detail?id=2397
2015-06-04 13:36:47 -07:00
Kenton Varda 10a149f333 Merge pull request #19 from jparyani/add-any-pointer-capability
Handle Capabilities that are typed as AnyPointers
2015-05-29 16:09:26 -07:00
Jason Paryani 32380dd1a6 Handle Capabilities that are typed as AnyPointers 2015-05-29 15:22:42 -07:00
Kenton Varda 54ad340ecf Cleanup: Remove #ifdefs to handle pre-0.5.x. 2015-05-28 17:17:35 -07:00
Kenton Varda 1199aa284a Cleanup: Use new capnp::Type to eliminate hacks. 2015-05-28 17:14:51 -07:00