Skip to content

fix fetch throw JavaScript error: Illegal invocation for service-binding and global env#202

Merged
syumai merged 1 commit into
syumai:fix-fetch-bindingfrom
labulakalia:main
May 4, 2026
Merged

fix fetch throw JavaScript error: Illegal invocation for service-binding and global env#202
syumai merged 1 commit into
syumai:fix-fetch-bindingfrom
labulakalia:main

Conversation

@labulakalia

@labulakalia labulakalia commented May 4, 2026

Copy link
Copy Markdown
Contributor

_example service-bindings/hello is work

@syumai

syumai commented May 4, 2026

Copy link
Copy Markdown
Owner

Thanks, but my fix is also almost done 🙏
https://github.com/syumai/workers/pull/new/fix-fetch-binding

@labulakalia

Copy link
Copy Markdown
Contributor Author

change namespace default is undefined will there be any other issue

@labulakalia

Copy link
Copy Markdown
Contributor Author

https://github.com/syumai/workers/blob/main/internal/jshttp/request.go#L19
return io.NopCloser(bytes.NewReader([]byte{})) will report err

panic: JavaScript error: Request with a GET or HEAD method cannot have a body.

goroutine 9 [running]:
syscall/js.Value.New({{}, 0x7ff8000400000011, 0x80c080}, {0x89d868, 0x2, 0x2})
	/home/labulakalia/sdk/go/src/syscall/js/js.go:501 +0x18
github.com/syumai/workers/internal/jshttp.ToJSRequest(0x894140)
	/home/labulakalia/workspace/workers/internal/jshttp/request.go:58 +0x13
github.com/syumai/workers/cloudflare/fetch.fetch({{}, 0x7ff8000100000038, 0x80c378}, 0x894140, 0x89d998)
	/home/labulakalia/workspace/workers/cloudflare/fetch/bind.go:23 +0xa
github.com/syumai/workers/cloudflare/fetch.(*transport).RoundTrip(0x8324e0, 0x894140)
	/home/labulakalia/workspace/workers/cloudflare/fetch/transport.go:17 +0x4
net/http.send(0x894140, {0x117a98, 0x8324e0}, {0x0, 0x0, 0x0})
	/home/labulakalia/sdk/go/src/net/http/client.go:259 +0x80
net/http.(*Client).send(0x8438f0, 0x894140, {0x0, 0x0, 0x0})
	/home/labulakalia/sdk/go/src/net/http/client.go:180 +0x12
net/http.(*Client).do(0x8438f0, 0x894140)
	/home/labulakalia/sdk/go/src/net/http/client.go:729 +0xca
net/http.(*Client).Do(...)
	/home/labulakalia/sdk/go/src/net/http/client.go:587
main.main.func1({0x11a008, 0x890050}, 0x894140)
	/home/labulakalia/workspace/workers/_examples/service-bindings/main.go:28 +0x2b
net/http.HandlerFunc.ServeHTTP(0xbcf70, {0x11a008, 0x890050}, 0x894140)
	/home/labulakalia/sdk/go/src/net/http/server.go:2322 +0x4
github.com/syumai/workers.handleRequest.func1()
	/home/labulakalia/workspace/workers/handler_js.go:81 +0x4
created by github.com/syumai/workers.handleRequest in goroutine 8
	/home/labulakalia/workspace/workers/handler_js.go:78 +0x29

@syumai

syumai commented May 4, 2026

Copy link
Copy Markdown
Owner

I want to add some changes, therefore I'll merge this into fix-fetch-binding branch

@syumai syumai changed the base branch from main to fix-fetch-binding May 4, 2026 09:56

@syumai syumai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@syumai syumai merged commit 9cbb10f into syumai:fix-fetch-binding May 4, 2026
2 checks passed
@syumai syumai mentioned this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants