smoldot 2.0.37 → 2.0.39

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.
@@ -54,7 +54,7 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
54
54
  eventCallback({ ty: "wasm-panic", message, currentTask: state.currentTask });
55
55
  state.onShutdownExecutorOrWasmPanic();
56
56
  state.onShutdownExecutorOrWasmPanic = () => { };
57
- throw new Error();
57
+ throw new Error("Smoldot has panicked");
58
58
  },
59
59
  chain_initialized: (chainId, errorMsgPtr, errorMsgLen) => {
60
60
  const instance = state.instance;
@@ -310,7 +310,12 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
310
310
  const whenReadyAgain = new Promise((resolve) => state.advanceExecutionPromise = () => resolve("ready"));
311
311
  if (!state.instance)
312
312
  break;
313
- state.instance.exports.advance_execution();
313
+ try {
314
+ state.instance.exports.advance_execution();
315
+ }
316
+ catch (_error) {
317
+ return;
318
+ }
314
319
  const afterExec = config.performanceNow();
315
320
  const elapsed = afterExec - now;
316
321
  now = afterExec;
@@ -396,7 +401,15 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
396
401
  buffer.writeUInt32LE(potentialRelayChainsEncoded, idx * 4, potentialRelayChains[idx]);
397
402
  }
398
403
  state.bufferIndices[2] = potentialRelayChainsEncoded;
399
- const chainId = state.instance.exports.add_chain(0, 1, disableJsonRpc ? 0 : jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, 2);
404
+ let chainId;
405
+ try {
406
+ chainId = state.instance.exports.add_chain(0, 1, disableJsonRpc ? 0 : jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, 2);
407
+ }
408
+ catch (_error) {
409
+ eventCallback({ ty: "add-chain-id-allocated", chainId: 0 });
410
+ eventCallback({ ty: "add-chain-result", chainId: 0, success: false, error: "Smoldot has crashed" });
411
+ return;
412
+ }
400
413
  delete state.bufferIndices[0];
401
414
  delete state.bufferIndices[1];
402
415
  delete state.bufferIndices[2];
@@ -405,7 +418,12 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
405
418
  removeChain: (chainId) => {
406
419
  if (!state.instance)
407
420
  return;
408
- state.instance.exports.remove_chain(chainId);
421
+ try {
422
+ state.instance.exports.remove_chain(chainId);
423
+ }
424
+ catch (_error) {
425
+ return;
426
+ }
409
427
  },
410
428
  shutdownExecutor: () => {
411
429
  if (!state.instance)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoldot",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
4
4
  "description": "Light client that connects to Polkadot and Substrate-based blockchains",
5
5
  "contributors": [
6
6
  "Parity Technologies <admin@parity.io>",