-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reproduction code of syumai/workers#100
- Loading branch information
Showing
7 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build | ||
node_modules | ||
.wrangler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.PHONY: dev | ||
dev: | ||
wrangler dev | ||
|
||
.PHONY: build | ||
build: | ||
go run github.com/syumai/workers/cmd/[email protected] -mode=go | ||
GOOS=js GOARCH=wasm go build -o ./build/app.wasm . | ||
|
||
.PHONY: deploy | ||
deploy: | ||
wrangler deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# syumai-workers-repro-issue-100 | ||
|
||
* A reproduction code of https://github.com/syumai/workers/issues/100 | ||
|
||
## Reproduction code | ||
|
||
* A HandlerFunc without writing response body causes weird error. | ||
|
||
```go | ||
func main() { | ||
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | ||
// doing nothing here causes weird error | ||
}) | ||
workers.Serve(nil) // use http.DefaultServeMux | ||
} | ||
``` | ||
|
||
## How to reproduce | ||
|
||
``` | ||
$ make dev # run this command in another terminal | ||
$ curl localhost:8787 | ||
TypeError: Cannot read properties of undefined (reading 'exports') | ||
at syscall/js.valueNew (file:///home/syumai/go/src/github.com/syumai/workers-playground/syumai-workers-repro-issue-100/build/wasm_exec.js:395:24) | ||
at [object Object] | ||
at [object Object] | ||
at [object Object] | ||
at [object Object] | ||
at [object Object] | ||
at globalThis.Go._resume (file:///home/syumai/go/src/github.com/syumai/workers-playground/syumai-workers-repro-issue-100/build/wasm_exec.js:553:23) | ||
at Object.handleRequest (file:///home/syumai/go/src/github.com/syumai/workers-playground/syumai-workers-repro-issue-100/build/wasm_exec.js:564:8) | ||
at Object.fetch (file:///home/syumai/go/src/github.com/syumai/workers-playground/syumai-workers-repro-issue-100/build/shim.mjs:51:18) | ||
at async jsonError (file:///home/syumai/.nvm/versions/node/v20.12.2/lib/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module github.com/syumai/workers-playground/syumai-workers-repro-issue-100 | ||
|
||
go 1.21.3 | ||
|
||
toolchain go1.22.2 | ||
|
||
require github.com/syumai/workers v0.23.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/syumai/workers v0.23.3 h1:7RZwe+EhOhLlFvrDMbgWFf2wc/G17i4uq4GsSG0uNrI= | ||
github.com/syumai/workers v0.23.3/go.mod h1:ZnqmdiHNBrbxOLrZ/HJ5jzHy6af9cmiNZk10R9NrIEA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/syumai/workers" | ||
) | ||
|
||
func main() { | ||
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | ||
// doing nothing here causes weird error | ||
}) | ||
workers.Serve(nil) // use http.DefaultServeMux | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name = "go-worker" | ||
main = "./build/worker.mjs" | ||
compatibility_date = "2024-04-15" | ||
|
||
[build] | ||
command = "make build" |