Skip to content

Commit b7d308d

Browse files
committed
fix(sim-setup): ignore a blank socket URL override
1 parent bd6c827 commit b7d308d

3 files changed

Lines changed: 30 additions & 13 deletions

File tree

‎apps/docs/scripts/fixtures/content-baseline.json‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172581,15 +172581,15 @@
172581172581
"lang": "bash",
172582172582
"meta": null,
172583172583
"sha256": "f6c25d1f99edeaa5029c6bae30235083b238b80b215b13eb7f3d5e34efabc9ee",
172584-
"bytes": 22,
172585-
"line": 28
172584+
"bytes": 21,
172585+
"line": 32
172586172586
},
172587172587
{
172588172588
"lang": "bash",
172589172589
"meta": null,
172590172590
"sha256": "c6e7fb800384d7d5ef95ed9a935fca407d1d5fa60a7d1efb17c5df96c1a82090",
172591-
"bytes": 62,
172592-
"line": 34
172591+
"bytes": 61,
172592+
"line": 38
172593172593
},
172594172594
{
172595172595
"lang": "bash",
@@ -172735,7 +172735,7 @@
172735172735
"lang": "bash",
172736172736
"meta": null,
172737172737
"sha256": "115d390d2a2ce355d6ecfe6a662b9e2f6e73f285ec4186638f676cb9eb9007c6",
172738-
"bytes": 14,
172738+
"bytes": 13,
172739172739
"line": 20
172740172740
},
172741172741
{
@@ -172756,7 +172756,7 @@
172756172756
"lang": "bash",
172757172757
"meta": null,
172758172758
"sha256": "ac53018b6ccf14d539980fc8206ce97fadc6a32220a60333cf7a8bef91f27f77",
172759-
"bytes": 196,
172759+
"bytes": 377,
172760172760
"line": 80
172761172761
},
172762172762
{
@@ -172867,7 +172867,9 @@
172867172867
{
172868172868
"lang": "bash",
172869172869
"meta": null,
172870-
"sha256": "fed433dfd89f812c99e9b905b5040307b08f5f828e78a6f6aa9322b7302b2264"
172870+
"sha256": "fed433dfd89f812c99e9b905b5040307b08f5f828e78a6f6aa9322b7302b2264",
172871+
"bytes": 20,
172872+
"line": 280
172871172873
}
172872172874
],
172873172875
"links": [
@@ -173422,7 +173424,7 @@
173422173424
"lang": "bash",
173423173425
"meta": null,
173424173426
"sha256": "115d390d2a2ce355d6ecfe6a662b9e2f6e73f285ec4186638f676cb9eb9007c6",
173425-
"bytes": 14,
173427+
"bytes": 13,
173426173428
"line": 24
173427173429
},
173428173430
{
@@ -176117,7 +176119,7 @@
176117176119
"lang": "bash",
176118176120
"meta": null,
176119176121
"sha256": "28b55f7fe8f07a34e08d95fd5517b6d6bbbb21984c824825fdeaf8e008a8158f",
176120-
"bytes": 140,
176122+
"bytes": 137,
176121176123
"line": 12
176122176124
},
176123176125
{
@@ -176562,8 +176564,8 @@
176562176564
"lang": "bash",
176563176565
"meta": null,
176564176566
"sha256": "8b1b7dd0aa41d3378e82618677b50ff44a7b9cbbe71038d2c1d30b5480c070bc",
176565-
"bytes": 275,
176566-
"line": 155
176567+
"bytes": 274,
176568+
"line": 157
176567176569
},
176568176570
{
176569176571
"lang": "bash",
@@ -176714,7 +176716,7 @@
176714176716
"lang": "bash",
176715176717
"meta": null,
176716176718
"sha256": "76422de41fcefba9fc85682b50cf9b41f5990ec1b095efb82638f80ac1d0bdc7",
176717-
"bytes": 21,
176719+
"bytes": 20,
176718176720
"line": 14
176719176721
},
176720176722
{

‎packages/sim-setup/src/checks.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,20 @@ describe('realtime reachability from the browser', () => {
160160
}
161161
)
162162

163+
it('treats a blank NEXT_PUBLIC_SOCKET_URL as unset, as the browser does', async () => {
164+
const findings = await runChecks(
165+
rootContext({
166+
NEXT_PUBLIC_APP_URL: 'http://192.168.1.10:3000',
167+
NEXT_PUBLIC_SOCKET_URL: ' ',
168+
}),
169+
['coherence']
170+
)
171+
172+
expect(
173+
findings.filter((finding) => finding.message.includes('NEXT_PUBLIC_SOCKET_URL'))
174+
).toEqual([expect.objectContaining({ status: 'warn' })])
175+
})
176+
163177
it('points an app served directly on :3000 at realtime on :3002', async () => {
164178
expect(await socketFindings('http://192.168.1.10:3000')).toEqual([
165179
expect.objectContaining({

‎packages/sim-setup/src/checks.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ function checkPostgresPassword(ctx: CheckContext): Finding[] {
387387
*/
388388
function checkSocketUrl(vars: ReadonlyMap<string, string>): Finding[] {
389389
const appUrl = vars.get('NEXT_PUBLIC_APP_URL')
390-
if (!appUrl || vars.get('NEXT_PUBLIC_SOCKET_URL')) return []
390+
// The browser trims the override and ignores it when blank, as getSocketUrl does.
391+
if (!appUrl || vars.get('NEXT_PUBLIC_SOCKET_URL')?.trim()) return []
391392
let origin: URL
392393
try {
393394
origin = new URL(appUrl)

0 commit comments

Comments
 (0)