Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Preview throws Server Error: 502 Bad Gateway #423

Closed
grempe opened this issue Aug 11, 2019 · 6 comments Β· Fixed by #429
Closed

Preview throws Server Error: 502 Bad Gateway #423

grempe opened this issue Aug 11, 2019 · 6 comments Β· Fixed by #429
Assignees
Milestone

Comments

@grempe
Copy link

grempe commented Aug 11, 2019

πŸ› Bug Report

Environment

  • operating system: macOS
  • output of rustc -V:
  • output of node -v:
  • output of wrangler -V:
➜ rustc -V
rustc 1.35.0 (3c235d560 2019-05-20)

➜ node -v                           
v10.16.0

➜ RUST_LOG=info RUST_BACKTRACE=1 ./node_modules/.bin/wrangler --version
πŸ‘· ✨   wrangler 1.1.1

Steps to reproduce

Run wrangler preview

What did you expect to see?

Clean build and display of preview.

What did you see instead?

➜ RUST_LOG=info RUST_BACKTRACE=1 ./node_modules/.bin/wrangler preview                    
[2019-08-11T22:01:13Z INFO  wrangler] Getting project settings
[2019-08-11T22:01:13Z INFO  wrangler::commands::build::wranglerjs] skipping npm install because node_modules exists
[2019-08-11T22:01:13Z INFO  wrangler::install] prebuilt artifact https://github.com/cloudflare/wrangler/releases/download/v1.1.1/wranglerjs-v1.1.1.tar.gz
⬇️ Installing wranglerjs...
[2019-08-11T22:01:13Z INFO  wrangler::commands::build::wranglerjs] wranglerjs downloaded at: "/Users/glenn/Library/Caches/.wrangler/wranglerjs-5b6f918ed4519a00"
[2019-08-11T22:01:13Z INFO  wrangler::commands::build::wranglerjs] skipping npm install because node_modules exists
[2019-08-11T22:01:13Z INFO  wrangler::install] prebuilt artifact https://github.com/rustwasm/wasm-pack/releases/download/v0.8.1/wasm-pack-v0.8.1-x86_64-apple-darwin.tar.gz
⬇️ Installing wasm-pack...
[2019-08-11T22:01:13Z INFO  wrangler::commands::build::wranglerjs] Running "/Users/glenn/.nvm/versions/node/v10.16.0/bin/node" "/Users/glenn/Library/Caches/.wrangler/wranglerjs-5b6f918ed4519a00" "--output-file=/var/folders/cg/q568zb_17fv6qx4r2lpl3g0w0000gn/T/.wranglerjs_outputwZuMa" "--wasm-binding=wasmprogram" "--no-webpack-config=1" "--use-entry=/Users/glenn/src/github.com/MYPROJ/MYPROJ-api-cloudflare/index.js"
✨   Built successfully, built project size is 22 KiB.
[2019-08-11T22:01:15Z INFO  wrangler::commands::publish::upload_form] Webpack project detected. Publishing...
[2019-08-11T22:01:15Z INFO  wrangler::commands::publish::upload_form] Form { boundary: "145b6e631ed14205892b639eb78c6655", parts: [("metadata", Part { value: Body { kind: b"{\"bindings\":[{\"name\":\"MYPROJ_API\",\"namespace_id\":\"REDACTED\",\"type\":\"kv_namespace\"}],\"body_part\":\"script\"}" }, mime: Some("application/json"), file_name: Some("metadata.json"), headers: {} }), ("script", Part { value: Body { kind: Reader { length: 66475 } }, mime: Some("application/javascript"), file_name: Some("script.js"), headers: {} })] }
Error: https://cloudflareworkers.com/script: Server Error: 502 Bad Gateway
stack backtrace:
   0: backtrace::backtrace::trace::h22584d25fbba1826 (0x10cfeb72e)
   1: backtrace::capture::Backtrace::new_unresolved::hfc9f84de61204b0b (0x10cfea818)
   2: failure::backtrace::internal::InternalBacktrace::new::hba46b32ce7838972 (0x10cfea029)
   3: <failure::backtrace::Backtrace as core::default::Default>::default::h24970bd4cf762182 (0x10cfea225)
   4: wrangler::commands::publish::preview::preview::h38fb112a3adb7a96 (0x10ccc775b)
   5: wrangler::run::h685661c5e5cdd2ad (0x10ccde593)
   6: wrangler::main::h29514711cbac4433 (0x10ccdbe75)
   7: std::rt::lang_start::{{closure}}::ha67eafa477c8744a (0x10ccdef56)
   8: std::panicking::try::do_call::h8037d9f03e27d896 (0x10d0fe8b8)
   9: __rust_maybe_catch_panic (0x10d1082ef)
  10: std::rt::lang_start_internal::hc8e69e673740d4ae (0x10d0ff39e)
  11: main (0x10ccded49)

➜ RUST_LOG=info RUST_BACKTRACE=1 ./node_modules/.bin/wrangler --version
πŸ‘· ✨   wrangler 1.1.1

FYI, running wrangler build, or wrangler publish runs cleanly and works as expected.

@ashleygwilliams
Copy link
Contributor

hi @grempe ! sorry you are running into this! can you tell me what sort of project this was? the preview service works on a basic js project for me- so it's possible you ran into something that was related to your script specifically- so any details around that would help me debug!

@ashleymichal
Copy link
Contributor

hey @grempe ! It looks like your project includes KV namespaces, which are not supported by the preview service. This is an unfortunate bug, but we have a partial fix for it started here: #424.

@ashleygwilliams ashleygwilliams added this to the 1.2.0 milestone Aug 12, 2019
@grempe
Copy link
Author

grempe commented Aug 12, 2019

Hmmm. Well, that seems like a pretty critical miss after the most recent release of official support for k/v in wrangler. It would certainly be better for developers if the preview service did support k/v. Even if it was mocked. Just declining to send k/v config (and adding conditional code for k/v as the PR seems to imply) doesn't seem like the right long term solution IMHO.

@ashleymichal
Copy link
Contributor

I agree that is not the correct long term solution. We have a few, more robust ideas around how to improve Wrangler's interactions with the preview service, however they are not slated for work this quarter. I'll write up the start of the RFC and link it here so you can track its progress. For now, to unblock folks, the fix in the above PR is our short term solution.

@ashleymichal
Copy link
Contributor

@grempe we met today to discuss this issue and decided to bump it to critical priority. Follow progress on this PR: #429. Thank you for your feedback!

@grempe
Copy link
Author

grempe commented Aug 13, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.