Skip to content

Commit 06aa2f7

Browse files
committed
Fix byte sizes
1 parent e301872 commit 06aa2f7

File tree

6 files changed

+23
-26
lines changed

6 files changed

+23
-26
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ on: [push]
44
jobs:
55
fmt:
66
runs-on: ubuntu-latest
7-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
7+
container: docker://nhooyr/websocket-ci@sha256:9f69035d64afdb2062a631d35748d46f440ecf2a1985845fc99b8c97ab14ca58
88
steps:
99
- uses: actions/checkout@v1
1010
with:
1111
fetch-depth: 1
1212
- run: ./ci/fmt.sh
1313
lint:
1414
runs-on: ubuntu-latest
15-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
15+
container: docker://nhooyr/websocket-ci@sha256:9f69035d64afdb2062a631d35748d46f440ecf2a1985845fc99b8c97ab14ca58
1616
steps:
1717
- uses: actions/checkout@v1
1818
with:
1919
fetch-depth: 1
2020
- run: ./ci/lint.sh
2121
test:
2222
runs-on: ubuntu-latest
23-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
23+
container: docker://nhooyr/websocket-ci@sha256:9f69035d64afdb2062a631d35748d46f440ecf2a1985845fc99b8c97ab14ca58
2424
steps:
2525
- uses: actions/checkout@v1
2626
with:
@@ -30,7 +30,7 @@ jobs:
3030
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3131
wasm:
3232
runs-on: ubuntu-latest
33-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
33+
container: docker://nhooyr/websocket-ci@sha256:9f69035d64afdb2062a631d35748d46f440ecf2a1985845fc99b8c97ab14ca58
3434
steps:
3535
- uses: actions/checkout@v1
3636
with:

ci/fmt.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fmt() {
1818
go run go.coder.com/go-tools/cmd/goimports -w "-local=$(go list -m)" .
1919
go run mvdan.cc/sh/cmd/shfmt -i 2 -w -s -sr .
2020
# shellcheck disable=SC2046
21-
npx prettier \
21+
npx -q prettier \
2222
--write \
2323
--print-width 120 \
2424
--no-semi \

ci/wasm.sh

+11-12
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@ set -euo pipefail
44
cd "$(dirname "${0}")"
55
cd "$(git rev-parse --show-toplevel)"
66

7-
stdout="$(mktemp -d)/stdout"
8-
mkfifo "$stdout"
9-
go run ./internal/wsecho/cmd > "$stdout" &
10-
11-
WS_ECHO_SERVER_URL="$(head -n 1 "$stdout")"
12-
137
GOOS=js GOARCH=wasm go vet ./...
8+
149
go install golang.org/x/lint/golint
1510
GOOS=js GOARCH=wasm golint -set_exit_status ./...
11+
12+
wsEchoOut="$(mktemp)"
13+
go run ./internal/wsecho/cmd >> "$wsEchoOut" &
14+
15+
WS_ECHO_SERVER_URL="$(tail -f "$wsEchoOut" | timeout 10s head -n 1)" || true
16+
if [[ -z $WS_ECHO_SERVER_URL ]]; then
17+
echo "./internal/wsecho/cmd failed to start in 10s"
18+
fi
19+
1620
go install github.com/agnivade/wasmbrowsertest
17-
GOOS=js GOARCH=wasm go test -exec="wasmbrowsertest" ./... -args "$WS_ECHO_SERVER_URL"
21+
GOOS=js GOARCH=wasm go test -exec=wasmbrowsertest ./... -args "$WS_ECHO_SERVER_URL"
1822

19-
echo kill
20-
jobs
2123
kill %1
22-
echo wait
2324
wait -n || true
24-
jobs
25-
echo over

internal/wsecho/wsecho.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ func Serve(w http.ResponseWriter, r *http.Request) {
3030

3131
// Loop echos every msg received from c until an error
3232
// occurs or the context expires.
33-
// The read limit is set to 1 << 40.
33+
// The read limit is set to 1 << 30.
3434
func Loop(ctx context.Context, c *websocket.Conn) {
3535
defer c.Close(websocket.StatusInternalError, "")
3636

37-
c.SetReadLimit(1 << 40)
37+
c.SetReadLimit(1 << 30)
3838

3939
ctx, cancel := context.WithTimeout(ctx, time.Minute)
4040
defer cancel()
4141

42-
b := make([]byte, 32768)
42+
b := make([]byte, 32<<10)
4343
echo := func() error {
4444
typ, r, err := c.Reader(ctx)
4545
if err != nil {

websocket_js_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ package websocket_test
22

33
import (
44
"context"
5+
"flag"
56
"net/http"
6-
"os"
77
"testing"
88
"time"
99

1010
"nhooyr.io/websocket"
1111
)
1212

13-
var wsEchoServerURL = os.Args[1]
14-
1513
func TestWebSocket(t *testing.T) {
1614
t.Parallel()
1715

18-
t.Skip("???")
16+
wsEchoServerURL := flag.Arg(0)
1917

2018
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
2119
defer cancel()

websocket_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ func TestAutobahn(t *testing.T) {
963963
return err
964964
}
965965
defer c.Close(websocket.StatusInternalError, "")
966-
c.SetReadLimit(1 << 40)
966+
c.SetReadLimit(1 << 30)
967967

968968
ctx := r.Context()
969969
if testingClient {
@@ -997,7 +997,7 @@ func TestAutobahn(t *testing.T) {
997997
t.Fatal(err)
998998
}
999999
defer c.Close(websocket.StatusInternalError, "")
1000-
c.SetReadLimit(1 << 40)
1000+
c.SetReadLimit(1 << 30)
10011001

10021002
if testingClient {
10031003
err = fn(ctx, c)

0 commit comments

Comments
 (0)