{"record":{"id":"3ad38802833dc22c","repo":"FuelLabs/fuels-rs","slug":"error-while-trying-to-fetch-wallets-from-the-custo","errorCode":null,"errorMessage":"Error while trying to fetch wallets from the custom provider","messagePattern":"Error while trying to fetch wallets from the custom provider","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fuels-macros/src/setup_program_test/code_gen.rs","lineNumber":103,"sourceCode":"    } else {\n        return Default::default();\n    };\n\n    let wallet_names = extract_wallet_names(&command);\n\n    if wallet_names.is_empty() {\n        return Default::default();\n    }\n\n    let num_wallets = wallet_names.len();\n    quote! {\n        let [#(#wallet_names),*]: [_; #num_wallets] = ::fuels::test_helpers::launch_custom_provider_and_get_wallets(\n            ::fuels::test_helpers::WalletsConfig::new(Some(#num_wallets as u64), None, None),\n            None,\n            None,\n        )\n        .await\n        .expect(\"Error while trying to fetch wallets from the custom provider\")\n        .try_into()\n        .expect(\"Should have the exact number of wallets\");\n    }\n}\n\nfn extract_wallet_names(command: &InitializeWalletCommand) -> Vec<Ident> {\n    command\n        .names\n        .iter()\n        .map(|name| ident(&name.value()))\n        .collect()\n}\n\nfn contract_deploying_code(\n    commands: &[DeployContractCommand],\n    project_lookup: &HashMap<String, Project>,\n) -> TokenStream {\n    commands","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/FuelLabs/fuels-rs/blob/d9a250a51818dda64bfeb5ef7cc19cf27bdcd623/packages/fuels-macros/src/setup_program_test/code_gen.rs#L85-L121","documentation":"setup_program_test! expands to test code that calls launch_custom_provider_and_get_wallets(WalletsConfig::new(n, ...)) when wallets are declared in the macro. The .await.expect panics when starting the local fuel-core provider or creating/funding the wallets fails, and the bare message hides the underlying error.","triggerScenarios":"Declaring wallets in setup_program_test! while the fuel-core binary required by the crate configuration cannot be fetched/executed, the provider port is already taken by a leftover process, or the local node crashes during wallet funding.","commonSituations":"Sandboxed CI without network to download the fuel-core binary; a previous test run left a fuel-core process holding the port; fuel-core version configured incompatibly.","solutions":["Kill leftover fuel-core processes / free the port the provider binds","Ensure the fuel-core binary is available (cached binary or network access) and matches the expected version","Reduce the number of wallets requested to lower startup pressure","Replace the macro-generated setup with a manual launch_custom_provider_and_get_wallets call using ? so the real error surfaces"],"exampleFix":"// before (inside setup_program_test!): generated code panics with a generic message\n// wallets(bob, alice),\n\n// after: manual setup with real error propagation\n#[tokio::test]\nasync fn my_test() -> anyhow::Result<()> {\n    let wallets = fuels::test_helpers::launch_custom_provider_and_get_wallets(\n        fuels::test_helpers::WalletsConfig::new(Some(2), None, None), None, None)\n        .await?; // underlying error is shown instead of a bare panic\n    Ok(())\n}","handlingStrategy":"try-catch","validationCode":"// Fail fast when the provider port is occupied before running the macro-generated setup\nlet port_free = std::net::TcpListener::bind((\"127.0.0.1\", 0)).is_ok();\nassert!(port_free, \"cannot bind local port for the test provider\");\n// (shell) kill leftover nodes: pkill -f fuel-core || true","typeGuard":null,"tryCatchPattern":"// Replace the macro-generated setup with manual setup and `?` so the real error surfaces\n#[tokio::test]\nasync fn my_test() -> anyhow::Result<()> {\n    let wallets = fuels::test_helpers::launch_custom_provider_and_get_wallets(\n        fuels::test_helpers::WalletsConfig::new(Some(2), None, None),\n        None,\n        None,\n    )\n    .await?;\n    Ok(())\n}","preventionTips":["Kill leftover fuel-core processes between test runs (CI teardown step)","Ensure the fuel-core binary is cached or downloadable in CI","Keep the number of test wallets small","Prefer manual setup over the macro when debugging provider startup"],"tags":["test-helpers","proc-macro","provider","wallet","local-node"],"backgroundTag":null,"analyzedSha":"d9a250a51818dda64bfeb5ef7cc19cf27bdcd623","analyzedAt":"2026-08-16T09:49:30.618Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}