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

🐛 BUG: r2 object put with --file not work #6642

Open
shama265 opened this issue Sep 6, 2024 · 9 comments
Open

🐛 BUG: r2 object put with --file not work #6642

shama265 opened this issue Sep 6, 2024 · 9 comments
Labels
bug Something that isn't working r2 Relating to R2

Comments

@shama265
Copy link

shama265 commented Sep 6, 2024

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
�[38;5;214m-------------------�[39m

---

--- 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
�[31m✘ �[41;31m[�[41;97mERROR�[41;31m]�[0m �[1mfetch failed�[0m


---

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

--- 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
�[38;5;214m-------------------�[39m

---

--- 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.
---
@shama265 shama265 added the bug Something that isn't working label Sep 6, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Sep 6, 2024
@cloudcreatr
Copy link

/workspaces/uni-saas/node_modules/wrangler/wrangler-dist/cli.js:29768
            throw a;
            ^

Error [AssertionError]: false == true
    at new AssertionError (node-internal:internal_assertionerror:427:15)
    at assert (node-internal:internal_assert:49:15)
    at Native (file:///workspaces/uni-saas/node_modules/wrangler/node_modules/miniflare/src/workers/core/proxy.worker.ts:141:4)
    at hydrate (file:///workspaces/uni-saas/node_modules/wrangler/node_modules/.pnpm/[email protected]/node_modules/devalue/src/parse.js:60:32)
    at unflatten (file:///workspaces/uni-saas/node_modules/wrangler/node_modules/.pnpm/[email protected]/node_modules/devalue/src/parse.js:132:9)
    at parse (file:///workspaces/uni-saas/node_modules/wrangler/node_modules/.pnpm/[email protected]/node_modules/devalue/src/parse.js:16:9)
    at #fetch (file:///workspaces/uni-saas/node_modules/wrangler/node_modules/miniflare/src/workers/core/proxy.worker.ts:220:43)
    at ProxyServer.fetch (file:///workspaces/uni-saas/node_modules/wrangler/node_modules/miniflare/src/workers/core/proxy.worker.ts:164:22) {
  [cause]: undefined
}

Node.js v20.16.0
error: script "dev" exited with code 7

i cant even do multi part upload locally, looks like some issue locally

@edmundhung edmundhung added the r2 Relating to R2 label Sep 16, 2024
@edmundhung
Copy link
Member

edmundhung commented Sep 16, 2024

Hi @shama265

Thanks for reporting this issue! I tried to reproduce the problem on my end, but it seems to be working fine. Could you please try running the command again with WRANGLER_LOG="debug" set in your environment? This will provide more detailed logs that might help us troubleshoot the issue further.

Let me know if you notice anything unusual in the debug output.

@shama265
Copy link
Author

Hi @edmundhung

Thanks for your response.
I tried to run same command with debug flag and I saw some additional message in a terminal. It seems to similar to the log I submitted first time. This log reports an error of missing .env file, but it also appears in the succeeded case (using --pipe).

Additionally, I attempted to run with a newer Wrangler (3.78.7). A run is failed again and logged similar.


(run with debug flag in 3.74.0, console)

$ WRANGLER_LOG="debug" yarn wrangler r2 object put mc-backup/backup.sh --file=backup.sh
🪵  Writing logs to "/home/******/.config/.wrangler/logs/wrangler-2024-09-21_00-32-43_555.log"
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'
}

 ⛅️ wrangler 3.74.0 (update available 3.78.7)
-------------------------------------------------------

No experimental flag store instantiated
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
Creating object "backup.sh" in bucket "mc-backup".
Retrieving cached values for account from node_modules/.cache/wrangler

✘ [ERROR] fetch failed


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
Note that there is a newer version of Wrangler available (3.78.7). Consider checking whether upgrading resolves this error.
✔ Would you like to report this error to Cloudflare? … yes
Sentry: Capturing exception TypeError: fetch failed

(in 3.78.7)

$ WRANGLER_LOG="debug" yarn wrangler r2 object put mc-backup/backup.sh --file=backup.sh
🪵  Writing logs to "/home/******/.config/.wrangler/logs/wrangler-2024-09-21_01-03-50_320.log"
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:3570:24)
    at makeCallSync.subPath.subPath (/home/******/mc-backup-tool/.pnp.cjs:4046:26)
    at ZipOpenFS.makeCallSync (/home/******/mc-backup-tool/.pnp.cjs:4698:14)
    at ZipOpenFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:4045:17)
    at VirtualFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3303:24)
    at PosixFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3303:24)
    at NodePathFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3303:24)
    at Object.readFileSync (node:fs:452:35)
    at NodeFS.readFileSync (/home/******/mc-backup-tool/.pnp.cjs:3883:24) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.env'
}

 ⛅️ wrangler 3.78.7
-------------------

No experimental flag store instantiated
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
Creating object "backup.sh" in bucket "mc-backup".
Retrieving cached values for account from node_modules/.cache/wrangler

✘ [ERROR] fetch failed


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
✔ Would you like to report this error to Cloudflare? … yes
Sentry: Capturing exception TypeError: fetch failed

@edmundhung
Copy link
Member

Hi @shama265,

Sorry, I’m still unable to pinpoint the issue exactly. It seems like a network problem, but it’s strange that --pipe works while --file doesn’t. Could you try uploading the same file using --pipe with WRANGLER_LOG="debug" enabled? This might help us spot any differences between the two methods and get closer to a solution.

Thanks for your patience!

@edmundhung edmundhung added the awaiting reporter response Needs clarification or followup from OP label Sep 23, 2024
@shama265
Copy link
Author

Hi @edmundhung ,

I tried to upload a same file with --pipe and WRANGLER_LOG="debug". It was successful.

$ cat backup.sh | WRANGLER_LOG="debug" yarn wrangler r2 object put mc-backup/backup.sh --pipe
🪵  Writing logs to "/home/******/.config/.wrangler/logs/wrangler-2024-09-24_09-28-43_832.log"
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:3568:24)
    at makeCallSync.subPath.subPath (/home/******/mc-backup-tool/.pnp.cjs:4044:26)
    at ZipOpenFS.makeCallSync (/home/******/mc-backup-tool/.pnp.cjs:4696:14)
    at ZipOpenFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:4043:17)
    at VirtualFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3301:24)
    at PosixFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3301:24)
    at NodePathFS.openSync (/home/******/mc-backup-tool/.pnp.cjs:3301:24)
    at Object.readFileSync (node:fs:452:35)
    at NodeFS.readFileSync (/home/******/mc-backup-tool/.pnp.cjs:3881:24) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.env'
}

 ⛅️ wrangler 3.74.0 (update available 3.78.8)
-------------------------------------------------------

No experimental flag store instantiated
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
Creating object "backup.sh" in bucket "mc-backup".
Checking if domain has Access enabled: dash.cloudflare.com
Access switch not cached for: dash.cloudflare.com
Caching access switch for: dash.cloudflare.com
Upload complete.

@lrapoport-cf lrapoport-cf added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Sep 30, 2024
@Master-Hash
Copy link

I can reproduce it on Windows 11, here's my log:

🪵  Writing logs to "C:\Users\hash\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-09-30_20-00-44_173.log"

 ⛅️ wrangler 3.78.12
--------------------

No experimental flag store instantiated
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
Configuration file belonging to ⚡️ Pages ⚡️ project detected.
Creating object "[REDACT]" in bucket "assets".

X [ERROR] fetch failed


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
√ Would you like to report this error to Cloudflare? ... yes
Sentry: Capturing exception TypeError: fetch failed
🪵  Logs were written to "C:\Users\hash\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-09-30_20-00-44_173.log"

No complain about .env not found, because I do have a .env file.

@edmundhung
Copy link
Member

Hi @Master-Hash

How about --pipe? Does it work for you similar to @shama265?

A few more things that I would love to know:

  • What is the yarn/node version you are using?
  • Do you see the same issue using npm/npx?
  • Is it still happening with the latest version of wrangler? If not, can you share the version you tried?

@edmundhung edmundhung added awaiting reporter response Needs clarification or followup from OP and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Nov 4, 2024
@Master-Hash
Copy link

Hi @edmundhung

I believe latest [email protected] doesn't solve this problem. Similar to @shama265, --pipe also works for me.

My node version is 23.0 and was 20.x lts (I forgot sorry), and yarn version is 4.5.1.

I can confirm it's a problem only when using yarn pnp. I tried yarn pnpm mode and it WORKS, so I believe npm is not affacted.

Thank you for your investigation!

@CarmenPopoviciu CarmenPopoviciu added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Nov 11, 2024
@CarmenPopoviciu
Copy link
Contributor

Hi @Master-Hash

Thx so much for confirming <3. This will take a bit of digging around on our side to understand why yarn pnp is failing here. Will follow up here with more details once we have them
🙏

@CarmenPopoviciu CarmenPopoviciu moved this from Untriaged to Backlog in workers-sdk Nov 11, 2024
@CarmenPopoviciu CarmenPopoviciu removed the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working r2 Relating to R2
Projects
Status: Backlog
Development

No branches or pull requests

6 participants