smoldot 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -363,11 +363,16 @@ function start(options, wasmModule, platformBindings) {
363
363
  if (state.instance.status !== "ready")
364
364
  throw new Error(); // Internal error. Never supposed to happen.
365
365
  state.instance.instance.shutdownExecutor();
366
- state.instance = { status: "destroyed", error: new public_types_js_1.AlreadyDestroyedError() };
366
+ // Wait for the `executor-shutdown` event to be generated.
367
+ yield new Promise((resolve) => state.onExecutorShutdownOrWasmPanic = resolve);
368
+ // In case the instance crashes while we were waiting, we don't want to overwrite
369
+ // the error.
370
+ if (state.instance.status === "ready")
371
+ state.instance = { status: "destroyed", error: new public_types_js_1.AlreadyDestroyedError() };
367
372
  state.connections.forEach((connec) => connec.reset());
368
373
  state.connections.clear();
369
374
  for (const addChainResult of state.addChainResults) {
370
- addChainResult({ success: false, error: "Smoldot has crashed" });
375
+ addChainResult({ success: false, error: "Client.terminate() has been called" });
371
376
  }
372
377
  state.addChainResults = [];
373
378
  for (const chain of Array.from(state.chains.values())) {
@@ -377,8 +382,6 @@ function start(options, wasmModule, platformBindings) {
377
382
  chain.jsonRpcResponsesPromises = [];
378
383
  }
379
384
  state.chains.clear();
380
- // Wait for the `executor-shutdown` event to be generated.
381
- yield new Promise((resolve) => state.onExecutorShutdownOrWasmPanic = resolve);
382
385
  })
383
386
  };
384
387
  }
@@ -142,12 +142,20 @@ export interface Chain {
142
142
  * The JSON-RPC callback will no longer be called. This is the case immediately after this
143
143
  * function is called. Any on-going JSON-RPC request is instantaneously aborted.
144
144
  *
145
- * Trying to use the chain again will lead to an exception being thrown.
145
+ * Trying to use the chain again will lead to a {@link AlreadyDestroyedError} exception
146
+ * being thrown.
146
147
  *
147
- * If this chain is a relay chain, then all parachains that use it will continue to work. Smoldot
148
- * automatically keeps alive all relay chains that have an active parachains. There is no need
149
- * to track parachains and relay chains, or to destroy them in the correct order, as this is
150
- * handled automatically internally.
148
+ * While the chain instantaneously disappears from the public API as soon as this function is
149
+ * called, its shutdown process actually happens asynchronously in the background. This means
150
+ * for example that networking connections to the chain will remain open for a little bit even
151
+ * after this function returns.
152
+ *
153
+ * If the chain is a relay chain, and that there exists {@link Chain} instances corresponding
154
+ * to parachains that are using this relay chain, then these parachains will continue to work
155
+ * and the relay chain will actually remain connected in the background.
156
+ * Smoldot automatically keeps alive all relay chains that have an active parachains. There
157
+ * is no need to track parachains and relay chains, or to destroy them in the correct order,
158
+ * as this is handled automatically internally.
151
159
  *
152
160
  * @throws {@link AlreadyDestroyedError} If the chain has already been removed or the client has been terminated.
153
161
  * @throws {@link CrashError} If the background client has crashed.