Skip to content

THRIFT-6435: Wait until the browser-test servers listen instead of sleeping - #4025

Open
Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:THRIFT-6435
Open

Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:THRIFT-6435

Conversation

@Jens-G

@Jens-G Jens-G commented Oct 19, 2026

Copy link
Copy Markdown
Member

The browser tests in lib/ts and lib/js start their Node test servers as async grunt tasks and then gave them one fixed second (the wait task) before headless Chrome loaded the first page. On a slow runner that is not always enough. lib-ts failed with net::ERR_CONNECTION_REFUSED at http://localhost:8089/test.html on master (dc83a92) and on #3753. Both times the server had not yet printed its "running on port" line, which normally appears about 0.3 s after the spawn.

wait now tries to connect to each server port every 100 ms and continues once all of them accept connections. The ports are 8089 in lib/ts and 8088 to 8091 in lib/js. A server that is still not listening after 30 seconds fails the task with Nothing is listening on port N after 30 seconds instead of surfacing as a refused connection in the browser. In the normal case the wait is shorter than the old second.

Verified in the thrift:jammy image. The compiler was built from this branch, and the image's Node is 20.20 (CI runs Node 22).

  • A plain grunt run passes in both directories. In lib/ts that is 25 + 1 tests. In lib/js it is all eleven QUnit pages, followed by concat, uglify and jsdoc. jshint reports both Gruntfiles clean, and both pass prettier --check.
  • I delayed the server start by 3 s through a temporary copy of each Gruntfile. The old wait reproduces the CI failure: lib/ts after 1.9 s, and lib/js on port 8089, or on test-es6.html when the 8088 server is the late one. The new wait holds until the late server listens. The lib/ts run then passes in 4.8 s. The lib/js runs used three pages, one each on 8089, 8091 and 8088, and they pass in 5.2 s.
  • With no server at all, the new wait in lib/ts fails after 30.5 s with the message above, and grunt exits with 3. The lib/js copy is the same code with a longer port list.

Not touched here: lib/nodejs/test/testAll.sh and lib/nodets/test/testAll.sh also start a server in the background and sleep a fixed time (0.1 s and 1 s) before starting the client. I haven't seen either fail.

JIRA: THRIFT-6435

  • Apache Jira ticket: THRIFT-6435
  • PR title follows "THRIFT-NNNN: describe my issue"
  • Single commit
  • Test change, so the commit carries no CI-skip marker.

🤖 Generated with Claude Code

…eeping

Client: js,ts

The test task in lib/ts and lib/js starts the Node test servers
asynchronously and then gave them one fixed second before headless Chrome
loaded the first page. On a slow CI runner that is not always enough, and
lib-ts failed with net::ERR_CONNECTION_REFUSED at
http://localhost:8089/test.html.

The wait task now tries to connect to each server port every 100 ms and
continues once all of them accept connections. A server that is still not
listening after 30 seconds fails the task with a message naming its port,
instead of surfacing as a refused connection in the browser test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Jens-G
Jens-G requested a review from emmenlau as a code owner October 19, 2026 12:13
@mergeable mergeable Bot added javascript Pull requests that update Javascript code typescript labels Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant