@miden-sdk/miden-sdk 0.14.10 → 0.14.11
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.
- package/dist/mt/{Cargo-DcB9UMnw.js → Cargo-CZopJ--X.js} +93 -116
- package/dist/mt/Cargo-CZopJ--X.js.map +1 -0
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +24 -32
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.js +53 -3
- package/dist/mt/index.js.map +1 -1
- package/dist/mt/wasm.js +1 -1
- package/dist/mt/workerHelpers.js +1 -1
- package/dist/mt/workers/{Cargo-DcB9UMnw-w3wXmKCr.js → Cargo-CZopJ--X-SsyOTzpb.js} +93 -116
- package/dist/mt/workers/Cargo-CZopJ--X-SsyOTzpb.js.map +1 -0
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +94 -117
- package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
- package/dist/mt/workers/workerHelpers.js +1 -1
- package/dist/st/{Cargo-CgOCogcE.js → Cargo-DC6jSekr.js} +103 -126
- package/dist/st/Cargo-DC6jSekr.js.map +1 -0
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +24 -32
- package/dist/st/eager.js +1 -1
- package/dist/st/index.js +53 -3
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/workers/{Cargo-CgOCogcE-dIBKWd7c.js → Cargo-DC6jSekr-BG7C7m56.js} +103 -126
- package/dist/st/workers/Cargo-DC6jSekr-BG7C7m56.js.map +1 -0
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +104 -127
- package/dist/st/workers/web-client-methods-worker.js.map +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
- package/package.json +1 -1
- package/dist/mt/Cargo-DcB9UMnw.js.map +0 -1
- package/dist/mt/workers/Cargo-DcB9UMnw-w3wXmKCr.js.map +0 -1
- package/dist/st/Cargo-CgOCogcE.js.map +0 -1
- package/dist/st/workers/Cargo-CgOCogcE-dIBKWd7c.js.map +0 -1
|
Binary file
|
|
@@ -1776,17 +1776,24 @@ export class IntoUnderlyingSource {
|
|
|
1776
1776
|
|
|
1777
1777
|
/**
|
|
1778
1778
|
* Represents an update to a single account's state.
|
|
1779
|
+
*
|
|
1780
|
+
* `inspectable` is intentionally omitted (see #2183). When `inspectable` is
|
|
1781
|
+
* set on a struct with public fields, wasm-bindgen auto-generates a
|
|
1782
|
+
* `toJSON()` method that reads every field-getter — each of which calls
|
|
1783
|
+
* back into WASM via `__wbg_get_<class>_<field>(this.__wbg_ptr)`. Under
|
|
1784
|
+
* Next.js 16.2 dev-mode the patched `console.*` runs every non-primitive
|
|
1785
|
+
* argument through `safe-stable-stringify`, which invokes `toJSON()`
|
|
1786
|
+
* automatically. If the underlying pointer has been freed (or another
|
|
1787
|
+
* WASM call is in flight) the resulting `"null pointer passed to rust"`
|
|
1788
|
+
* trap propagates out of the user's `console.log` and crashes the
|
|
1789
|
+
* caller. Without `inspectable`, no `toJSON()` is emitted; JSON.stringify
|
|
1790
|
+
* falls back to `{}` (the wasm-bindgen wrapper has no own enumerable
|
|
1791
|
+
* data — it's all behind the `__wbg_ptr`), and the re-entry never
|
|
1792
|
+
* happens. Field access via the named getters still works exactly as
|
|
1793
|
+
* before; only the auto-stringification path is muted.
|
|
1779
1794
|
*/
|
|
1780
1795
|
export class JsAccountUpdate {
|
|
1781
1796
|
private constructor();
|
|
1782
|
-
/**
|
|
1783
|
-
** Return copy of self without private attributes.
|
|
1784
|
-
*/
|
|
1785
|
-
toJSON(): Object;
|
|
1786
|
-
/**
|
|
1787
|
-
* Return stringified version of self.
|
|
1788
|
-
*/
|
|
1789
|
-
toString(): string;
|
|
1790
1797
|
free(): void;
|
|
1791
1798
|
[Symbol.dispose](): void;
|
|
1792
1799
|
/**
|
|
@@ -1905,17 +1912,12 @@ export class JsStateSyncUpdate {
|
|
|
1905
1912
|
|
|
1906
1913
|
/**
|
|
1907
1914
|
* A JavaScript representation of a storage map entry in an account.
|
|
1915
|
+
*
|
|
1916
|
+
* `inspectable` is intentionally omitted — see the note on
|
|
1917
|
+
* `JsAccountUpdate` for the full rationale (#2183).
|
|
1908
1918
|
*/
|
|
1909
1919
|
export class JsStorageMapEntry {
|
|
1910
1920
|
private constructor();
|
|
1911
|
-
/**
|
|
1912
|
-
** Return copy of self without private attributes.
|
|
1913
|
-
*/
|
|
1914
|
-
toJSON(): Object;
|
|
1915
|
-
/**
|
|
1916
|
-
* Return stringified version of self.
|
|
1917
|
-
*/
|
|
1918
|
-
toString(): string;
|
|
1919
1921
|
free(): void;
|
|
1920
1922
|
[Symbol.dispose](): void;
|
|
1921
1923
|
/**
|
|
@@ -1934,17 +1936,12 @@ export class JsStorageMapEntry {
|
|
|
1934
1936
|
|
|
1935
1937
|
/**
|
|
1936
1938
|
* A JavaScript representation of a storage slot in an account.
|
|
1939
|
+
*
|
|
1940
|
+
* `inspectable` is intentionally omitted — see the note on
|
|
1941
|
+
* `JsAccountUpdate` for the full rationale (#2183).
|
|
1937
1942
|
*/
|
|
1938
1943
|
export class JsStorageSlot {
|
|
1939
1944
|
private constructor();
|
|
1940
|
-
/**
|
|
1941
|
-
** Return copy of self without private attributes.
|
|
1942
|
-
*/
|
|
1943
|
-
toJSON(): Object;
|
|
1944
|
-
/**
|
|
1945
|
-
* Return stringified version of self.
|
|
1946
|
-
*/
|
|
1947
|
-
toString(): string;
|
|
1948
1945
|
free(): void;
|
|
1949
1946
|
[Symbol.dispose](): void;
|
|
1950
1947
|
/**
|
|
@@ -1963,17 +1960,12 @@ export class JsStorageSlot {
|
|
|
1963
1960
|
|
|
1964
1961
|
/**
|
|
1965
1962
|
* An object that contains a serialized vault asset.
|
|
1963
|
+
*
|
|
1964
|
+
* `inspectable` is intentionally omitted — see the note on
|
|
1965
|
+
* `JsAccountUpdate` for the full rationale (#2183).
|
|
1966
1966
|
*/
|
|
1967
1967
|
export class JsVaultAsset {
|
|
1968
1968
|
private constructor();
|
|
1969
|
-
/**
|
|
1970
|
-
** Return copy of self without private attributes.
|
|
1971
|
-
*/
|
|
1972
|
-
toJSON(): Object;
|
|
1973
|
-
/**
|
|
1974
|
-
* Return stringified version of self.
|
|
1975
|
-
*/
|
|
1976
|
-
toString(): string;
|
|
1977
1969
|
free(): void;
|
|
1978
1970
|
[Symbol.dispose](): void;
|
|
1979
1971
|
/**
|
package/dist/mt/eager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getWasmOrThrow } from './index.js';
|
|
2
2
|
export { AccountArray, AccountIdArray, AccountType, AuthScheme, CompilerResource, FeltArray, ForeignAccountArray, Linking, MidenArrays, MidenClient, MockWasmWebClient, NoteAndArgsArray, NoteArray, NoteIdAndArgsArray, NoteRecipientArray, NoteVisibility, OutputNoteArray, StorageMode, StorageSlotArray, TransactionScriptInputPairArray, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, resolveAuthScheme } from './index.js';
|
|
3
|
-
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-
|
|
3
|
+
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-CZopJ--X.js';
|
|
4
4
|
import './wasm.js';
|
|
5
5
|
|
|
6
6
|
// Eager entry point for @miden-sdk/miden-sdk.
|
package/dist/mt/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import loadWasm from './wasm.js';
|
|
2
|
-
import { AccountArray as AccountArray$1, AccountIdArray as AccountIdArray$1, FeltArray as FeltArray$1, ForeignAccountArray as ForeignAccountArray$1, NoteAndArgsArray as NoteAndArgsArray$1, NoteArray as NoteArray$1, NoteIdAndArgsArray as NoteIdAndArgsArray$1, NoteRecipientArray as NoteRecipientArray$1, OutputNoteArray as OutputNoteArray$1, StorageSlotArray as StorageSlotArray$1, TransactionScriptInputPairArray as TransactionScriptInputPairArray$1 } from './Cargo-
|
|
3
|
-
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-
|
|
2
|
+
import { AccountArray as AccountArray$1, AccountIdArray as AccountIdArray$1, FeltArray as FeltArray$1, ForeignAccountArray as ForeignAccountArray$1, NoteAndArgsArray as NoteAndArgsArray$1, NoteArray as NoteArray$1, NoteIdAndArgsArray as NoteIdAndArgsArray$1, NoteRecipientArray as NoteRecipientArray$1, OutputNoteArray as OutputNoteArray$1, StorageSlotArray as StorageSlotArray$1, TransactionScriptInputPairArray as TransactionScriptInputPairArray$1 } from './Cargo-CZopJ--X.js';
|
|
3
|
+
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-CZopJ--X.js';
|
|
4
4
|
|
|
5
5
|
const WorkerAction = Object.freeze({
|
|
6
6
|
INIT: "init",
|
|
@@ -1583,6 +1583,26 @@ class MidenClient {
|
|
|
1583
1583
|
* race the proxy's chain and trip wasm-bindgen's "recursive use of an
|
|
1584
1584
|
* object detected" panic.
|
|
1585
1585
|
*
|
|
1586
|
+
* Re-entrancy: while `fn` is running, the underlying client's
|
|
1587
|
+
* `_withInnerLockDepth` counter is bumped so that `_serializeWasmCall`
|
|
1588
|
+
* invocations made BY `fn` (or any proxy-dispatched method it calls)
|
|
1589
|
+
* run inline rather than enqueuing on the chain. Without this, every
|
|
1590
|
+
* `await inner.X(...)` inside `fn` would enqueue behind the outer
|
|
1591
|
+
* `_withInnerWebClient` slot which is itself awaiting `fn` —
|
|
1592
|
+
* a classic re-entrant-lock deadlock. The depth counter restores the
|
|
1593
|
+
* intent of the docstring above: the lock is held for the duration
|
|
1594
|
+
* of `fn`, and inner-client calls "borrow" that already-held lock
|
|
1595
|
+
* instead of trying to re-acquire it.
|
|
1596
|
+
*
|
|
1597
|
+
* SAFETY CONTRACT for re-entrancy: callers MUST hold an external
|
|
1598
|
+
* mutex preventing concurrent access to this same client instance
|
|
1599
|
+
* via other code paths during `fn`. The chain still serializes
|
|
1600
|
+
* against external callers — they queue behind the outer slot — but
|
|
1601
|
+
* if an external task runs during one of `fn`'s awaits and calls
|
|
1602
|
+
* into the SDK, it will see `_withInnerLockDepth > 0` and run
|
|
1603
|
+
* inline, racing wasm-bindgen's borrow check. The wallet pattern
|
|
1604
|
+
* (own outer mutex around `_withInnerWebClient`) satisfies this.
|
|
1605
|
+
*
|
|
1586
1606
|
* Stability: marked `@internal`. The shape of the proxied client is
|
|
1587
1607
|
* intentionally not part of the documented public API and may change
|
|
1588
1608
|
* between SDK versions. If you depend on this method, pin the SDK
|
|
@@ -1602,7 +1622,15 @@ class MidenClient {
|
|
|
1602
1622
|
if (typeof fn !== "function") {
|
|
1603
1623
|
throw new TypeError("_withInnerWebClient: fn must be a function");
|
|
1604
1624
|
}
|
|
1605
|
-
|
|
1625
|
+
const inner = this.#inner;
|
|
1626
|
+
return inner._serializeWasmCall(async () => {
|
|
1627
|
+
inner._withInnerLockDepth = (inner._withInnerLockDepth || 0) + 1;
|
|
1628
|
+
try {
|
|
1629
|
+
return await fn(inner);
|
|
1630
|
+
} finally {
|
|
1631
|
+
inner._withInnerLockDepth--;
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1606
1634
|
}
|
|
1607
1635
|
|
|
1608
1636
|
/**
|
|
@@ -2573,6 +2601,11 @@ class WebClient {
|
|
|
2573
2601
|
// would panic with "recursive use of an object detected" due to
|
|
2574
2602
|
// wasm-bindgen's internal RefCell.
|
|
2575
2603
|
this._wasmCallChain = Promise.resolve();
|
|
2604
|
+
// Depth counter for `_withInnerWebClient` re-entrancy. While > 0,
|
|
2605
|
+
// `_serializeWasmCall` runs its callback inline instead of queueing
|
|
2606
|
+
// it on the chain — see the comment on `_serializeWasmCall` for the
|
|
2607
|
+
// safety contract.
|
|
2608
|
+
this._withInnerLockDepth = 0;
|
|
2576
2609
|
}
|
|
2577
2610
|
|
|
2578
2611
|
/**
|
|
@@ -2586,10 +2619,27 @@ class WebClient {
|
|
|
2586
2619
|
* without it, concurrent main-thread callers would panic with
|
|
2587
2620
|
* "recursive use of an object detected" (wasm-bindgen's internal RefCell).
|
|
2588
2621
|
*
|
|
2622
|
+
* Re-entrancy: when invoked from inside a `_withInnerWebClient(fn)`
|
|
2623
|
+
* callback — detected via `_withInnerLockDepth > 0` — `fn` runs inline
|
|
2624
|
+
* (no chain enqueue). The outer `_withInnerWebClient` invocation
|
|
2625
|
+
* already holds the chain via its own wrapping `_serializeWasmCall`,
|
|
2626
|
+
* so enqueueing the inner call would deadlock (the inner queues
|
|
2627
|
+
* behind the outer; the outer awaits the inner). The inline run is
|
|
2628
|
+
* safe because the chain still serializes against external callers
|
|
2629
|
+
* — they queue behind the outer call's chain slot, which only resolves
|
|
2630
|
+
* after `fn` (including all inline re-entries) settles. Callers of
|
|
2631
|
+
* `_withInnerWebClient` MUST hold an external mutex preventing
|
|
2632
|
+
* concurrent access via other code paths on this same instance during
|
|
2633
|
+
* the callback; without that, an external task running between two
|
|
2634
|
+
* awaits inside `fn` would race wasm-bindgen's borrow check.
|
|
2635
|
+
*
|
|
2589
2636
|
* @param {() => Promise<any>} fn - The async function to execute.
|
|
2590
2637
|
* @returns {Promise<any>} The result of fn.
|
|
2591
2638
|
*/
|
|
2592
2639
|
_serializeWasmCall(fn) {
|
|
2640
|
+
if (this._withInnerLockDepth > 0) {
|
|
2641
|
+
return Promise.resolve().then(fn);
|
|
2642
|
+
}
|
|
2593
2643
|
const result = this._wasmCallChain.catch(() => {}).then(fn);
|
|
2594
2644
|
this._wasmCallChain = result.catch(() => {});
|
|
2595
2645
|
return result;
|