Commit graph

1576 commits

Author SHA1 Message Date
joeduffy f3088149ec Make scripts agnostic to pwd 2017-09-07 21:29:50 -07:00
joeduffy 8180914f83 Don't keep the message loop alive during logging 2017-09-07 21:14:29 -07:00
joeduffy 4e96400c9e Only print leaks on successful exits 2017-09-07 15:19:08 -07:00
joeduffy ebc3bf1dd0 Reap the language host process 2017-09-07 15:03:48 -07:00
joeduffy a5a6c79925 Keep RPC connections alive for as long as we need them
The change to tear down RPC connections after the program exits --
to fix problems on Linux presumably due to the way libuv is implemented --
unfortunately introduces nondeterminism and overzealous termination that
can happen at inopportune times.  Instead, we need to wait for the current
RPC queue to drain.  To fix this, we'll maintain a list of currently active
RPC calls and, only once they have completed, will we close the clients.
2017-09-07 14:50:17 -07:00
joeduffy c6b626899b Flatten the Node.js SDK release structure 2017-09-07 14:33:00 -07:00
joeduffy 88a87569f5 Link the bin/ directory
This moves us closer to what we'll have with real NPM packages.
2017-09-07 12:43:12 -07:00
joeduffy b23338d4d1 Disconnect from the host/engine properly 2017-09-07 12:33:43 -07:00
Joe Duffy 0e3a01c684 Update the publish scripts for the new package structure (#334) 2017-09-07 11:07:52 -07:00
joeduffy d845c9e08c Publish and install the new layout 2017-09-07 09:56:26 -07:00
joeduffy 7f41f6e186 Update dependencies to latest 2017-09-07 09:02:15 -07:00
Joe Duffy dbd0e2ad4b Merge pull request #328 from pulumi/311_v8
Switch to a Node.js/V8-based runtime
2017-09-07 08:41:25 -07:00
joeduffy dcefa4a9d4 Close gRPC client connections
This change closes the gRPC client connections, as they keep the
Node.js message loop alive on Linux (but, strangely, not Mac;
regardless, a good thing to do anyway...)
2017-09-07 08:32:36 -07:00
joeduffy f64b8e25e7 Clean up legacy examples 2017-09-07 07:59:16 -07:00
joeduffy 6147afb7d1 Fix cp command on Linux 2017-09-07 07:36:10 -07:00
joeduffy 0d2f84c194 Fix github.com/pkg/errors reference 2017-09-07 07:25:08 -07:00
joeduffy 470a519057 Add Promises leak and hang detection
We have an issue in the runtime right now where we serialize closures
asynchronously, meaning we make it possible to form cycles between
resource graphs (something that ought to be impossible in our model,
where resources are "immutable" after creation and cannot form cycles).

Let me tell you a tale of debugging this ...

Well, no, let's not do that.  But thankfully I've left behind some
little utilities that might make debugging such a thing easier down
the road.  Namely:

* By default, most of our core runtime promises leverage a leak handler
  that will log an error message should the process exit with certain
  critical unresolved promises.  This error message will include some
  handy context (like whether it was an input promise) as well as a
  stack trace for its point of creation.

* Optionally, with a flag in runtime/debuggable.ts, you may wire up
  a hang detector, for situations where we may want to detect this
  situation sooner than process exit, using the regular message loop.
  This uses a defined timeout, prints the same diagnostics as the
  leak detector when a hang is detected, and is disabled by default.
2017-09-06 18:35:20 -07:00
joeduffy 93743733fb Explicitly serialize output properties in closures 2017-09-06 14:51:00 -07:00
joeduffy aefe297aa1 Harden dependent resolutions
This fixes a few problems with dependent resolutions and hardens
even more promises-related error paths, so we swallow precisely zero
errors (or at least we hope so).  This also digs through multi-level
chains of promises and computed properties as needed for nested mapValues.
2017-09-06 14:29:17 -07:00
joeduffy 397fea5720 Permit undefined values to flow through 2017-09-06 09:39:16 -07:00
joeduffy d8d94d1df0 Harden error paths and improve messages 2017-09-06 09:36:28 -07:00
joeduffy f0389799d8 Convey errors if any error messages occurred 2017-09-06 09:35:35 -07:00
joeduffy 7e5b6a564c Let assets/archives contain computeds 2017-09-06 08:59:23 -07:00
joeduffy ca149316fc Block resource creations within mapValue 2017-09-06 08:49:20 -07:00
joeduffy 240b54b5be Add typings and tests for mapValues that return computeds 2017-09-06 08:28:11 -07:00
joeduffy 0f08ef3cda Improve mapValue: log errors, permit Computed<U> returns 2017-09-06 08:10:30 -07:00
joeduffy 6630de503c Support capturing Computed<T>s and Promise<T>s
This change adds support for awaiting any Computed<T> and Promise<T>s
that were captured inside of a function's closure.  This preserves our
ability to capture, for example, resource state that ends up getting
serialized as the final resource state, rather than a snapshot of the
(mostly unresolved) resource state at the time of serialization.
2017-09-06 07:36:19 -07:00
joeduffy cc9a607f01 Move environment entry serialization into JavaScript
This change moves the environment entry serialization logic into
JavaScript, where it's a bit easier to author and maintain.  We
also switch to using Object.keys, so that we only walk the enumerable
properties of objects (to avoid internal member functions and to
generally leverage our current style of writing code).  This is
just a temporary stopgap until we figure out more rigorous semantics
for what it means to serialize entire objects ...
2017-09-05 16:57:23 -07:00
joeduffy fc236ec0b2 Override toString from Property
This is mostly just for debugging purposes, but hopefully makes it
a little clearer that you've done something wrong, vs "[object Object]".
2017-09-05 15:51:05 -07:00
joeduffy 726e48e094 Add an extra test for nested functions 2017-09-05 15:50:47 -07:00
joeduffy 3164572b6e Fix some free variable capture logic
* Use `global.hasOwnProperty(ident)`, rather than `global[ident] !== undefined`,
  to avoid classifying references to globals as free variables.  Surprise(!!),
  the prior logic wouldn't work for `undefined` itself... 😒

* Expand this check to include the built-in Node.js module variables, namely
  `__dirname`, `__filename`, `exports`, `module`, and `require`, so that
  references to them don't get classified as serializable free variables either.

* Place catch variables in scope, so that `catch (err) { ... }` won't yield
  free variables for references to `err` within `...`.

* Place recursive function definitions into the top-level `var`-like scope of
  variables so that we don't consider references to them free.

* Harden all error pathways in the native C++ add-on so that we terminate
  anytime an exception is in-flight, rather than limping along and making
  things worse...
2017-09-05 15:21:14 -07:00
joeduffy 0a78ef0743 Properly report closes due to signals 2017-09-05 12:01:55 -07:00
joeduffy e3a6695399 Depend only on vendored protos 2017-09-05 11:52:33 -07:00
joeduffy 8d3708f34d Use portable cps 2017-09-05 11:39:32 -07:00
joeduffy 4b2a40056e Remove proto/ from sdk/nodejs/ 2017-09-05 11:39:10 -07:00
joeduffy 8826c08116 Fix linting glob 2017-09-05 11:24:38 -07:00
joeduffy d3bd43fea9 Rename PropertyValue<T> to MaybeComputed<T>
As I started rolling this out, I realized that end user code actually
has to use this type sometimes.  And that the current names are inconsistent,
after eschewing Property<T> in favor of Computed<T>.  The new names read better.
2017-09-05 11:14:28 -07:00
joeduffy a1ab56fc28 Prettify properties
This change makes a few simplifications to how properties are exposed in
the system, mostly in the name of usability, but also to feel a bit more
like "idiomatic JavaScript".  Namely:

* Rename `then` to `mapValue`.  This hopefully helps to suggest that this
  is meant for a dataflow style of programming.

* Move Property<T> into the runtime module, and remove PropertyState<T>,
  collapsing back down to a single type.  This also eliminates some of the
  messy internal runtime casting, accessing of internal members, etc.

* Export a Computed<T> interface from the root of the module.  This is
  the entirety of the public-facing surface area for properties, and
  exposes that single `mapValue` member function.  The internal runtime
  logic understands how to handle Property<T>s specifically in addition
  to Computed<T>s more generally (in case someone writes their own).
2017-09-05 10:55:09 -07:00
joeduffy ad54031fb2 Install Node.js 6.10.x in Travis 2017-09-05 10:26:05 -07:00
joeduffy 2e824c0ba5 Reject all but Node.js 6.10.x 2017-09-05 10:08:20 -07:00
joeduffy f2d53459eb Add the notion of stable states
If a resource's planning operation is to do nothing, we can safely
assume that all of its properties are stable.  This can be used during
planning to avoid cascading updates that we know will never happen.
2017-09-05 10:01:00 -07:00
joeduffy 2a22a71116 Tidy up resource properties
This changes a few aspects of resource properties:

* Move all runtime-related goo into the runtime module, in an
  internal PromiseState class.  This encapsulates the internal
  state transitions and protects against misuse.  It also allows
  us to clean up the public API for the Property<T> type so that
  it's entirely suitable for external usage.

* Track input and output property values distinctly.  It turns
  out we want to key off events differently.  For example, to marshal
  property values to a resource provider, we only care about the
  inputs.  For final property values that are used in, say, thens
  or as inputs to other properties, we want the output property value.

* Be more precise about when an output is truly final, and known, or
  unknown due to planning/dry-runs.  Note that this does mean that
  we'll encounter unknown values more frequently because, aside from
  IDs and URNs, we can't say for sure that arbitrary properties will never
  change post-creation.  We have ideas on how to denote this; see
  pulumi/pulumi-fabric#330 for more details.
2017-09-05 09:31:03 -07:00
joeduffy d7c90f12a8 Use yarn to run subcommands 2017-09-04 11:35:21 -07:00
joeduffy b80b6afcf1 Lint the test files 2017-09-04 11:35:21 -07:00
joeduffy 7c7610848f Rename asset classes
This change renames String, File, and Remote to StringAsset, FileAsset,
and RemoteAsset, largely to avoid conflicting with the built-in JavaScript
String type, but also because it mirrors our Archive naming strategy.
2017-09-04 11:35:21 -07:00
joeduffy f3cf73d790 Change plugin prefixes to "pulumi-" 2017-09-04 11:35:21 -07:00
joeduffy 1c52e2d607 Run the node_modules version of node-gyp 2017-09-04 11:35:21 -07:00
joeduffy ee7fc0a8c5 Fix a few things in the SDK
This fixes a few things in the SDK preventing deployments (versus plans):

* Don't fully resolve when a link resolves.  This will be handled during
  the final completion of the resource state.

* Skip "id" and "urn" for property resolution, since they are handled
  explicitly based on the RPC messages.  The "id" is often in the response
  payload because Terraform stores it as a property.  We don't need it.

* Lazily allocate Property<T> objects if necessary when the response
  from the resulting resource operation comes back.

* Improve a few error messages.
2017-09-04 11:35:21 -07:00
joeduffy fe66a0eba7 Use the new URN during creates 2017-09-04 11:35:21 -07:00
joeduffy 77bbf443bc Synchronize with the resource channel properly 2017-09-04 11:35:21 -07:00