cloudflare / cloudflare/workers-sdk

🐛 BUG: `r2 object put` with `--file` not work

Open
#6,642 9 comments 1 reaction 0 assignees View on GitHub
package:wrangler product:r2
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### Which Cloudflare product(s) does this pertain to?

R2

### What version(s) of the tool(s) are you using?

3.74.0

### What version of Node are you using?

v20.17.0

### What operating system and version are you using?

Debian 12

### Describe the Bug

### Observed behavior
`r2 object put` is failure, cause error `fetch failed`.
The file is not uploaded to bucket.

### Expected behavior
Upload to my bucket

### Steps to reproduce
- `yarn wrangler r2 object put some-bucket/somefile.txt --file=somefile.txt`

### Appendix
Instead of using `--pipe`, upload is complete.

```
$ cat backup.sh | yarn wrangler r2 object put sample-st/backup.sh --pipe

⛅️ wrangler 3.74.0
-------------------

Creating object "backup.sh" in bucket "sample-st".
Upload complete.
```

### Please provide a link to a minimal reproduction

_No response_

### Please provide any relevant error logs

(shell)
```
$ yarn wrangler r2 object put mc-backup/backup.sh --file=backup.sh

⛅️ wrangler 3.74.0
-------------------

Creating object "backup.sh" in bucket "mc-backup".

✘ [ERROR] fetch failed
```

(log)
```
--- 2024-09-06T04:57:07.553Z debug
🪵 Writing logs to "/home/******/.config/.wrangler/logs/wrangler-2024-09-06_04-57-07_378.log"
---

--- 2024-09-06T04:57:07.553Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
at Object.openSync (node:fs:573:18)
at NodeFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3559:24)
at makeCallSync.subPath.subPath (/home/******/mc-backup-tool/.pnp.cjs:4035:26)
at ZipOpenFS.makeCallSync (/home/******/mc-backup-tool/.pnp.cjs:4687:14)
at ZipOpenFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:4034:17)
at VirtualFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3292:24)
at PosixFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3292:24)
at NodePathFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3292:24)
at Object.readFileSync (node:fs:452:35)
at NodeFS.readFileSync (/home/******/mc-backup-tool/.pnp.cjs:3872:24) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '.env'
}
---

--- 2024-09-06T04:57:07.562Z log

⛅️ wrangler 3.74.0
-------------------

---

--- 2024-09-06T04:57:07.563Z debug
No experimental flag store instantiated
---

--- 2024-09-06T04:57:07.563Z debug
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
---

--- 2024-09-06T04:57:07.568Z log
Creating object "hoge.txt" in bucket "sample-st".
---

--- 2024-09-06T04:57:07.874Z log

---

--- 2024-09-06T04:57:08.037Z error
✘ [ERROR] fetch failed

---

--- 2024-09-06T04:57:08.038Z log
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
---

--- 2024-09-06T04:57:09.720Z debug
Sentry: Capturing exception TypeError: fetch failed
---
```

(log, using `--pipe`)
```

--- 2024-09-06T04:46:14.119Z debug
🪵 Writing logs to "/home/******/.config/.wrangler/logs/wrangler-2024-09-06_04-46-13_946.log"
---

--- 2024-09-06T04:46:14.119Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
at Object.openSync (node:fs:573:18)
at NodeFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3559:24)
at makeCallSync.subPath.subPath (/home/******/mc-backup-tool/.pnp.cjs:4035:26)
at ZipOpenFS.makeCallSync (/home/******/mc-backup-tool/.pnp.cjs:4687:14)
at ZipOpenFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:4034:17)
at VirtualFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3292:24)
at PosixFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3292:24)
at NodePathFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3292:24)
at Object.readFileSync (node:fs:452:35)
at NodeFS.readFileSync (/home/******/mc-backup-tool/.pnp.cjs:3872:24) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '.env'
}
---

--- 2024-09-06T04:46:14.132Z log

⛅️ wrangler 3.74.0
-------------------

---

--- 2024-09-06T04:46:14.133Z debug
No experimental flag store instantiated
---

--- 2024-09-06T04:46:14.133Z debug
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
---

--- 2024-09-06T04:46:14.138Z log
Creating object "backup.sh" in bucket "sample-st".
---

--- 2024-09-06T04:46:15.650Z log
Upload complete.
---
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `yarn wrangler r2 object put some-bucket/somefile.txt --file=somefile.txt` and compare it with the working `--pipe` command. Trace the `r2 object put` CLI entry point and its file-upload path; done means `--file` uploads successfully and a regression test covers the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.