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: Wrangler crashes trying to export a local database containing a BLOB column #8226

Open
vlovich opened this issue Feb 23, 2025 · 0 comments
Labels
bug Something that isn't working d1 Relating to D1

Comments

@vlovich
Copy link

vlovich commented Feb 23, 2025

Which Cloudflare product(s) does this pertain to?

D1, Wrangler

What versions are you using?

3.109.0 Wrangler, 23.8.0 NodeJS

What operating system and version are you using?

Arch Linux

Please provide a link to a minimal reproduction

No response

Describe the Bug

I have a BLOB column that has a non-null value (random 16 byte ArrayBuffer had been inserted filled in by crypto.randomValues) and trying to do npx wrangler d1 --env debug export DB --local --output test.sql crashes with:

✘ [ERROR] D1_ERROR: Failed to parse body as JSON, got: TypeError: cell.replace is not a function
      at outputQuotedEscapedString

Running a normal execute --command 'SELECT * from table_with_blob;' dumps the data as expected without issue.

Please provide any relevant error logs


--- 2025-02-23T02:27:37.258Z debug
🪵  Writing logs to "/home/vlovich/.config/.wrangler/logs/wrangler-2025-02-23_02-27-37_214.log"
---

--- 2025-02-23T02:27:37.258Z debug
Metrics dispatcher: Posting data {"deviceId":"e68e62e5-762a-4607-bbf3-df6fb7fdc050","event":"wrangler command started","timestamp":1740277657258,"properties":{"amplitude_session_id":1740277657257,"amplitude_event_id":0,"wranglerVersion":"3.109.0","osPlatform":"Linux","osVersion":"#1 SMP PREEMPT_DYNAMIC Fri, 10 Jan 2025 00:39:41 +0000","nodeVersion":23,"packageManager":"npm","isFirstUsage":false,"configFileType":"jsonc","isCI":false,"isPagesCI":false,"isWorkersCI":false,"isInteractive":true,"hasAssets":false,"argsUsed":["e","env","local","output"],"argsCombination":"e, env, local, output","command":"wrangler d1 export","args":{"env":"<REDACTED>","e":"<REDACTED>","local":true,"output":"<REDACTED>","xJsonConfig":true,"j":true,"schema":true,"data":true,"name":"<REDACTED>"}}}
---

--- 2025-02-23T02:27:37.262Z debug
.env file not found at ".env.debug". Continuing... For more details, refer to https://developers.cloudflare.com/workers/wrangler/system-environment-variables/
---

--- 2025-02-23T02:27:37.262Z debug
.env file not found at ".env". Continuing... For more details, refer to https://developers.cloudflare.com/workers/wrangler/system-environment-variables/
---

--- 2025-02-23T02:27:37.278Z log

 ⛅️ wrangler 3.109.0 (update available �[32m3.109.2�[39m)
�[38;2;255;136;0m---------------------------------------------------------�[39m

---

--- 2025-02-23T02:27:37.280Z debug
No experimental flag store instantiated
---

--- 2025-02-23T02:27:37.280Z debug
Attempted to use flag "RESOURCES_PROVISION" which has not been instantiated
---

--- 2025-02-23T02:27:37.281Z log
🌀 Exporting local database DB (dcd51e38-8b47-4aa9-8ef7-5eabe3db7383) from .wrangler/state/v3/d1:
---

--- 2025-02-23T02:27:37.281Z log
🌀 To export your remote database, add a --remote flag to your wrangler command.
---

--- 2025-02-23T02:27:37.395Z log
🌀 Exporting SQL to ../test.sql...
---

--- 2025-02-23T02:27:37.534Z log

---

--- 2025-02-23T02:27:37.642Z error
�[31m✘ �[41;31m[�[41;97mERROR�[41;31m]�[0m �[1mD1_ERROR: Failed to parse body as JSON, got: TypeError: cell.replace is not a function�[0m

      at outputQuotedEscapedString
  (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:67:196)
      at
  file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:53:143
      at Array.map (<anonymous>)
      at dumpSql
  (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:51:36)
      at dumpSql.next (<anonymous>)
      at Array.from (<anonymous>)
      at #doExportData
  (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:337:23)
      at D1DatabaseObject.queryExecute
  (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:320:32)
      at async D1DatabaseObject.fetch
  (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/shared/index.worker.js:380:18)
      at async D1DatabaseObject.fetch
  (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/shared/index.worker.js:545:14)


---

--- 2025-02-23T02:27:37.671Z debug
Error: D1_ERROR: Failed to parse body as JSON, got: TypeError: cell.replace is not a function
    at outputQuotedEscapedString (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:67:196)
    at file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:53:143
    at Array.map (<anonymous>)
    at dumpSql (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:51:36)
    at dumpSql.next (<anonymous>)
    at Array.from (<anonymous>)
    at #doExportData (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:337:23)
    at D1DatabaseObject.queryExecute (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/d1/database.worker.js:320:32)
    at async D1DatabaseObject.fetch (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/shared/index.worker.js:380:18)
    at async D1DatabaseObject.fetch (file:///home/vlovich/projects/the-engine/server-evaluate/node_modules/miniflare/dist/src/workers/shared/index.worker.js:545:14)
    at exportLocal (/home/vlovich/projects/the-engine/server-evaluate/node_modules/wrangler/wrangler-dist/cli.js:134540:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Object.Handler [as handler] (/home/vlovich/projects/the-engine/server-evaluate/node_modules/wrangler/wrangler-dist/cli.js:134507:12)
---

--- 2025-02-23T02:27:37.672Z debug
Metrics dispatcher: Posting data {"deviceId":"e68e62e5-762a-4607-bbf3-df6fb7fdc050","event":"wrangler command errored","timestamp":1740277657672,"properties":{"amplitude_session_id":1740277657257,"amplitude_event_id":1,"wranglerVersion":"3.109.0","osPlatform":"Linux","osVersion":"#1 SMP PREEMPT_DYNAMIC Fri, 10 Jan 2025 00:39:41 +0000","nodeVersion":23,"packageManager":"npm","isFirstUsage":false,"configFileType":"jsonc","isCI":false,"isPagesCI":false,"isWorkersCI":false,"isInteractive":true,"hasAssets":false,"argsUsed":["e","env","local","output"],"argsCombination":"e, env, local, output","command":"wrangler d1 export","args":{"env":"<REDACTED>","e":"<REDACTED>","local":true,"output":"<REDACTED>","xJsonConfig":true,"j":true,"schema":true,"data":true,"name":"<REDACTED>"},"durationMs":422,"durationSeconds":0.422,"durationMinutes":0.007033333333333333,"errorType":"UserError"}}
---
@vlovich vlovich added the bug Something that isn't working label Feb 23, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Feb 23, 2025
@emily-shen emily-shen added the d1 Relating to D1 label Feb 24, 2025
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 d1 Relating to D1
Projects
Status: Untriaged
Development

No branches or pull requests

2 participants