infisical icon indicating copy to clipboard operation
infisical copied to clipboard

Infisical hangs indefinitely when executing any Bun v1.2.9 command

Open seawatts opened this issue 8 months ago • 5 comments

Describe the bug

When using infisical run to execute any Bun command, the process hangs indefinitely. This happens regardless of whether it's a direct Bun command or through script chaining.

To Reproduce

Steps to reproduce the behavior:

  1. Set up a project with infisical
  2. Create test scripts in package.json:
{
  "scripts": {
    "test1": "infisical run -- bun --version",
    "test2": "infisical run -- echo 'hello'",
    "test3": "infisical run --command 'bun --version'",
    "test4": "bun with-env echo 'test with-env'"
  }
}
  1. Run the scripts:
# These hang indefinitely:
bun test1  # Using -- with bun command
bun test3  # Using --command with bun command
bun test4  # Using script chaining with bun

# This works fine:
bun test2  # Using infisical with non-bun command

Expected behavior

Any command run through infisical should:

  1. Execute normally, whether it's a Bun command or not
  2. Show output from the command
  3. Complete execution
  4. Exit normally

Platform you are having the issue on:

  • OS: macOS 14.7.4
  • Bun version: 1.2.9
  • Infisical version: 0.39.1

Additional context

  • This issue affects ANY usage of Bun commands through infisical
  • The command hangs without any error message or output
  • The process needs to be manually killed with Ctrl+C
  • Non-Bun commands work fine through infisical
  • The same Bun commands work fine when not run through infisical
  • The issue occurs with both the -- delimiter and --command flag approaches

Workarounds

  1. Use bun 1.2.8

or

  1. Use npm/yarn/pnpm:
# All of these work:
pnpm test1  # Using -- with bun command
pnpm test3  # Using --command with bun command
pnpm test4  # Using script chaining with bun
pnpm test2  # Using infisical with non-bun command
  1. Avoid using Bun commands through infisical entirely if possible
  2. Use direct shell commands instead of Bun where possible

seawatts avatar Apr 11 '25 19:04 seawatts

Hey Seawatts,

I tried to recreate this issue but everything seems to work fine for me.

OS: macOS 15.3.2 Bun version: 1.2.9 Infisical version: 0.39.1

I tried this in several terminals and used both new and old versions for both Infisical and Bun. I also tried this on two different Infisical projects, one that contained a few secrets and one that didn't. In all instances everything worked fine.

Try to run your commands with --log-level trace and it'll output debug information. Here's the full command: infisical run --log-level trace -- bun --version

Image

x032205 avatar Apr 12 '25 22:04 x032205

Thanks for the prompt response @x032205, and through reproduction. However, I'm still seeing the same issue.

Here is my output with log level trace. The execution hangs after that. NOTE: I removed the full path and variables here.

 bun test3
$ infisical run --log-level trace -- bun --version
12:39PM DBG FindWorkspaceConfigFile: workspace file found at [path=.infisical.json]
12:39PM DBG GetEnvelopmentBasedOnGitBranch: [envBasedOnGitBranch=] [ok=false]
12:39PM DBG getEnvelopmentBasedOnGitBranch: [err=%!s(<nil>)]
12:39PM DBG FindWorkspaceConfigFile: workspace file found at [path=.infisical.json]
12:39PM DBG FindWorkspaceConfigFile: workspace file found at [path=.infisical.json]
12:39PM DBG GetAllEnvironmentVariables: Trying to fetch secrets using logged in details
12:39PM DBG GetAllEnvironmentVariables: Connected to Infisical instance, checking logged in creds
12:39PM DBG FindWorkspaceConfigFile: workspace file found at [path=.infisical.json]
12:39PM DBG GetAllEnvironmentVariables: Trying to fetch secrets JTW token [err=%!s(<nil>)]
12:39PM DBG injecting the following environment variables into shell: [XXXXXXX]
12:39PM INF Injecting 32 Infisical secrets into your application process
12:39PM DBG executing command: /bin/zsh -c bun --version 
// .infisical.json
{
  "workspaceId": "XXXX",
  "defaultEnvironment": "",
  "gitBranchToEnvironmentMapping": null
}

Extra context, I am logged into two different users with Infisical, so I am running infisical user switch to select the account before running that command. Not sure if that would matter here.

Separate note, it would be cool to be able to have the cli just know which account it needs to use for that workspace instead of me having to type user switch each time I go back and forth between projects, which is multiple times a day.

seawatts avatar Apr 14 '25 19:04 seawatts

Could you try just running /bin/zsh -c 'bun --version'? This could help us figure out if the issue is with your shell or not.

x032205 avatar Apr 14 '25 20:04 x032205

% /bin/zsh -c 'bun --version'
1.2.9

seawatts avatar Apr 14 '25 21:04 seawatts

I found repro steps:

  1. Install a new package with bun add x or update the dependencies with bun update
  2. Try to run the commands above. This will hang still.
  3. Remove node_modules and run bun install
  4. Run the commands above and it works.

seawatts avatar Apr 25 '25 17:04 seawatts