Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] WebSocket index out of bounds #11192

Open
Warchant opened this issue May 20, 2024 · 1 comment
Open

[windows] WebSocket index out of bounds #11192

Warchant opened this issue May 20, 2024 · 1 comment
Labels
crash An issue that could cause a crash web-api Something that relates to a standard Web API

Comments

@Warchant
Copy link

Warchant commented May 20, 2024

How can we reproduce the crash?

  1. bun init - use all defaults
  2. Create index.ts from below code
  3. Run a ggxchain node:
docker run -it --rm -p 9944:9944 --entrypoint /usr/src/app/target/release/ggxchain-node ggxdocker/ggxnode:brooklyn-405e709 --dev --tmp --rpc-external
  1. bun run index.ts - run this on Windows 11. See log as below.

JavaScript/TypeScript code that reproduces the crash?

import { ApiPromise, Keyring, WsProvider } from "@polkadot/api";
import { cryptoWaitReady } from '@polkadot/util-crypto';


async function sendAndWaitForFinalized(tx: any, senderKeypair: any): Promise<void> {
    // Sign and send the transaction
    const unsub = await tx.signAndSend(senderKeypair, ({ status }: any) => {
        if (status.isInBlock) {
            console.log(`Transaction included at blockHash ${status.asInBlock}`);
        } else if (status.isFinalized) {
            console.log(`Transaction finalized at blockHash ${status.asFinalized}`);
            unsub();
        }
    });
}

async function main() {
    await cryptoWaitReady();

    // Construct
    const wsProvider = new WsProvider('ws://127.0.0.1:9944');
    const keyring = new Keyring({ type: 'sr25519' });
    const alice = keyring.addFromUri('//Alice');
    const bob = keyring.addFromUri('//Bob');


    const api = await ApiPromise.create({ provider: wsProvider });

    await api.isReadyOrError;

    try {
        // Send a transfer from Alice to Bob
        const transfer = api.tx.balances.transfer(bob.address, 12345);
        await sendAndWaitForFinalized(transfer, alice);

        // Query Bob's balance
        const { data: { free: previousFree }, nonce: previousNonce } = await api.query.system.account(bob.address);
        console.log(`Bob's balance is ${previousFree}, nonce is ${previousNonce}`);
    }
    catch (error) {
        console.log(error);
    }
}


main().catch(console.error);

Relevant log output

(3) > bun run index.ts
2024-05-20 12:42:16        API/INIT: RPC methods not decorated: btcRelay_verifyBlockHeaderInclusion, issue_getIssueRequests, issue_getVaultIssueRequests, oracle_collateralToWrapped, oracle_wrappedToCollateral, redeem_getRedeemRequests, redeem_getVaultRedeemRequests, replace_getNewVaultReplaceRequests, replace_getOldVaultReplaceRequests, vaultRegistry_getCollateralizationFromVault, vaultRegistry_getCollateralizationFromVaultAndCollateral, vaultRegistry_getIssueableTokensFromVault, vaultRegistry_getPremiumRedeemVaults, vaultRegistry_getRequiredCollateralForVault, vaultRegistry_getRequiredCollateralForWrapped, vaultRegistry_getVaultCollateral, vaultRegistry_getVaultTotalCollateral, vaultRegistry_getVaultsByAccountId, vaultRegistry_getVaultsWithIssuableTokens, vaultRegistry_getVaultsWithRedeemableTokens
2024-05-20 12:42:16        API/INIT: ggxchain-node/12: Not decorating unknown runtime apis: BtcRelayApi/1, VaultRegistryApi/1, IssueApi/1, RedeemApi/1, ReplaceApi/1
Bob's balance is 200000000000000000000012345, nonce is 0
============================================================
Bun v1.1.8 (89d25807) Windows x64
Args: "C:\Users\warch\scoop\apps\bun\current\bun.exe", "run", "index.ts"
Features: jsc transpiler_cache(5) tsconfig_paths(2) tsconfig(4) WebSocket 
Builtins: "bun:main" "node:buffer" "node:crypto" "node:string_decoder" "node:util" "node:util/types" "ws" "node-fetch" 
RSS: 0.37GB | Peak: 0.37GB | Commit: 4.74GB | Faults: 93033

panic(main thread): index out of bounds
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.8/wr189d2580AiggggX2j59Qk7z6Ts369Qu9ir2C8u0ne4ttkegzqkek37xG2t9t1C6r+pFA0eNrLzEtJrVDILy1RyE9TSMovzUspBgBHeAcx

Stack Trace (bun.report)

Bun v1.1.8 (89d2580) on windows x86_64 [RunCommand]

panic: index out of bounds

@Warchant Warchant added the crash An issue that could cause a crash label May 20, 2024
@Electroid Electroid changed the title Bun crashes on Windows WebSocket index out of bounds May 20, 2024
@Electroid Electroid added the web-api Something that relates to a standard Web API label May 20, 2024
@Warchant
Copy link
Author

Warchant commented May 23, 2024

Same for 1.1.9:

Bun v1.1.9 (bb13798) on windows x86_64 [RunCommand]

panic: index out of bounds

@Warchant Warchant changed the title WebSocket index out of bounds [windows] WebSocket index out of bounds May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash web-api Something that relates to a standard Web API
Projects
None yet
Development

No branches or pull requests

2 participants