Skip to content

EBADF 'Garbage collection failed' error during sanity dataset import #11750

@cameronwlewis

Description

@cameronwlewis

Describe the bug
During a CI/CD script running via Github Actions, I got the following error on the step in which it ran npx sanity dataset import staging-backup.tar.gz production --replace --project <my-project>:

- [0%] Reading/validating data file (0.00s)
✓ [100%] Reading/validating data file (614ms)
- [0%] Importing documents (0.00s)
✓ [100%] Importing documents (2s)
- [0%] Importing assets (files/images) (0.00s)
<anonymous_script>:0


[Error: EBADF: Closing file descriptor 31 on garbage collection failed, close] {
  errno: -9,
  code: 'EBADF',
  syscall: 'close'
}

This command worked fine on v4 of Sanity CLI in Github Actions, and I started noticing the problems when I bumped the Sanity version to 5.2.0.

To Reproduce

Steps to reproduce the behavior:

Run npx sanity dataset import staging-backup.tar.gz production --replace --project <my-project> on Node 20 or 22 in a CI/CD or similar setting (Ubuntu-latest), with Sanity CLI version of 5.1.0 or 5.2.0.

Expected behavior

Clearly I expected it to work as it had in past versions of the Sanity CLI running on Node 20.

Which versions of Sanity are you using?

As of experiencing this bug, I downgraded (and the error stopped):

@sanity/cli (global)           5.0.0 (latest: 5.2.0)
@sanity/cli                    5.0.0 (latest: 5.2.0)
@sanity/color-input            6.0.1 (latest: 6.0.3)
@sanity/dashboard              5.0.0 (latest: 5.0.1)
@sanity/eslint-config-studio   5.0.2 (latest: 6.0.0)
@sanity/image-url              1.2.0 (latest: 2.0.2)
@sanity/preview-url-secret    2.1.15 (latest: 4.0.2)
@sanity/vision                4.10.3 (latest: 5.2.0)
sanity                         5.0.0 (latest: 5.2.0)

What operating system are you using?

MacOS, but this bug is happening on Github's action runner

Which versions of Node.js / npm are you running?

See above.

Additional context

The error eventually disappeared when I downgraded to Sanity 5.0.0. The error occurred on Sanity 5.1.0 and 5.2.0 on both Node 20 and Node 22 (I tested all combinations). So clearly some issue was introduced in either Sanity 5.0.1 or later.

Security issue?

I sure hope not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions