Skip to content

Commit fed112f

Browse files
justin808claude
andcommitted
Address PR review comments
- Remove check_early_hints.js/py from .gitignore (Comment #1) - Fix ESLint/Prettier issues in check_early_hints.js: - Move require('ws') to top of file - Replace msgId++ with msgId += 1 - Wrap single-arg arrow params in parentheses - Add process.exit(1) when no Chrome tabs found in JS file (Comment #4) - Add explicit sys.exit() for success/failure in Python file (Comment #5) - Add language identifiers to fenced code blocks in docs/thruster.md (Comment #6) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 714d825 commit fed112f

4 files changed

Lines changed: 38 additions & 33 deletions

File tree

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,3 @@ client/app/bundles/comments/rescript/**/*.bs.js
6767

6868
.claude/
6969
.context/
70-
71-
# Chrome DevTools debug scripts (development-only)
72-
check_early_hints.js
73-
check_early_hints.py

check_early_hints.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const http = require('http');
2+
const WebSocket = require('ws');
23

34
// Fetch Chrome tabs
45
const req = http.get('http://localhost:9222/json', (res) => {
@@ -13,15 +14,14 @@ const req = http.get('http://localhost:9222/json', (res) => {
1314

1415
if (tabs.length === 0) {
1516
console.log('No Chrome tabs found');
16-
return;
17+
process.exit(1);
1718
}
1819

1920
const tab = tabs[0];
2021
console.log(`📱 Tab: ${tab.title}`);
2122
console.log(`🔗 URL: ${tab.url}\n`);
2223

2324
// Connect to WebSocket
24-
const WebSocket = require('ws');
2525
const ws = new WebSocket(tab.webSocketDebuggerUrl);
2626

2727
let msgId = 1;
@@ -30,26 +30,32 @@ const req = http.get('http://localhost:9222/json', (res) => {
3030
console.log('✅ Connected to Chrome DevTools Protocol\n');
3131

3232
// Enable Runtime
33-
ws.send(JSON.stringify({
34-
id: msgId++,
35-
method: 'Runtime.enable'
36-
}));
33+
ws.send(
34+
JSON.stringify({
35+
id: msgId,
36+
method: 'Runtime.enable',
37+
}),
38+
);
39+
msgId += 1;
3740

3841
// Get HTML content
3942
setTimeout(() => {
40-
ws.send(JSON.stringify({
41-
id: msgId++,
42-
method: 'Runtime.evaluate',
43-
params: {
44-
expression: 'document.documentElement.outerHTML'
45-
}
46-
}));
43+
ws.send(
44+
JSON.stringify({
45+
id: msgId,
46+
method: 'Runtime.evaluate',
47+
params: {
48+
expression: 'document.documentElement.outerHTML',
49+
},
50+
}),
51+
);
52+
msgId += 1;
4753
}, 500);
4854
});
4955

50-
ws.on('message', (data) => {
56+
ws.on('message', (msgData) => {
5157
try {
52-
const msg = JSON.parse(data);
58+
const msg = JSON.parse(msgData);
5359

5460
if (msg.result && msg.result.result && msg.result.result.value) {
5561
const html = msg.result.result.value;
@@ -62,7 +68,7 @@ const req = http.get('http://localhost:9222/json', (res) => {
6268
if (earlyHintsMatch) {
6369
earlyHintsFound = true;
6470
console.log('🎉 Found Early Hints debug comments in HTML!\n');
65-
earlyHintsMatch.forEach(match => {
71+
earlyHintsMatch.forEach((match) => {
6672
console.log(match);
6773
console.log();
6874
});
@@ -79,7 +85,7 @@ const req = http.get('http://localhost:9222/json', (res) => {
7985
const linkMatches = html.match(/<link[^>]*rel=["']preload["'][^>]*>/g);
8086
if (linkMatches) {
8187
console.log(`\n📦 Found ${linkMatches.length} preload links in HTML head:`);
82-
linkMatches.slice(0, 5).forEach(link => {
88+
linkMatches.slice(0, 5).forEach((link) => {
8389
console.log(` ${link}`);
8490
});
8591
}

check_early_hints.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
22
import json
3+
import re
4+
import sys
35
import urllib.request
46
import websocket
57
import ssl
@@ -10,7 +12,7 @@
1012

1113
if not tabs:
1214
print("No Chrome tabs found")
13-
exit(1)
15+
sys.exit(1)
1416

1517
# Use the first tab (the one we saw with the PR review app)
1618
tab = tabs[0]
@@ -60,7 +62,6 @@
6062
print("🎉 Found Early Hints debug comments in HTML!\n")
6163

6264
# Extract the comments
63-
import re
6465
matches = re.findall(r'<!--[\s\S]*?Early Hints[\s\S]*?-->', html)
6566
for match in matches:
6667
print(match)
@@ -84,6 +85,8 @@
8485

8586
if found_early_hints:
8687
print("\n✅ SUCCESS: Early Hints are working!")
88+
sys.exit(0)
8789
else:
8890
print("\n⚠️ Could not verify Early Hints in the current page state")
8991
print("The page may need to be reloaded to capture HTTP 103 responses")
92+
sys.exit(1)

docs/thruster.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ After running `bundle install`, the `thrust` executable is available.
4141
All Procfiles in this project have been updated to use Thruster:
4242

4343
#### Production (`Procfile`)
44-
```
44+
```text
4545
web: bundle exec thrust bin/rails server
4646
```
4747

4848
#### Development with HMR (`Procfile.dev`)
49-
```
49+
```text
5050
rails: bundle exec thrust bin/rails server -p 3000
5151
```
5252

5353
#### Development with Production Assets (`Procfile.dev-prod-assets`)
54-
```
54+
```text
5555
web: bundle exec thrust bin/rails server -p 3001
5656
```
5757

5858
#### Development with Static Webpack (`Procfile.dev-static`)
59-
```
59+
```text
6060
web: bundle exec thrust bin/rails server -p 3000
6161
```
6262

6363
#### Development with Static Assets (`Procfile.dev-static-assets`)
64-
```
64+
```text
6565
web: bundle exec thrust bin/rails server -p 3000
6666
```
6767

@@ -122,7 +122,7 @@ Thruster will automatically:
122122

123123
When the server starts, you'll see Thruster initialization in the logs:
124124

125-
```
125+
```text
126126
[thrust] Starting Thruster HTTP/2 proxy
127127
[thrust] Proxying to http://localhost:3000
128128
[thrust] Serving from ./public
@@ -134,7 +134,7 @@ When the server starts, you'll see Thruster initialization in the logs:
134134

135135
Thruster works seamlessly with Heroku. The standard `Procfile` is already configured:
136136

137-
```
137+
```text
138138
web: bundle exec thrust bin/rails server
139139
```
140140

@@ -208,7 +208,7 @@ Thruster will automatically:
208208

209209
Thruster logs important events:
210210

211-
```
211+
```text
212212
[thrust] Starting Thruster HTTP/2 proxy
213213
[thrust] Proxying to http://localhost:3000
214214
[thrust] Serving from ./public
@@ -273,12 +273,12 @@ config.public_file_server.headers = {
273273
### From Puma Early Hints
274274

275275
Previous configuration:
276-
```
276+
```text
277277
web: bundle exec puma -C config/puma.rb --early-hints
278278
```
279279

280280
New configuration:
281-
```
281+
```text
282282
web: bundle exec thrust bin/rails server
283283
```
284284

0 commit comments

Comments
 (0)