also looking at this
fix: allow runtime arenas within a finite runner address budget
#7
13 files
+298
-12
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -71,6 +71,10 @@ because that is what actually listens. | ||
| 71 | 71 | hide. |
| 72 | 72 | - [x] A Discover feed of public activity, with trending and recently active repositories beside it |
| 73 | 73 | |
| 74 | The shared feed reader imports its database binding explicitly, so static rendering does not | |
| 75 | depend on application preloader globals. A fresh-process regression uses a local adapter | |
| 76 | fixture without a database service; normal preview CI also renders against migrated Postgres. | |
| 77 | ||
| 74 | 78 | The event's recorded visibility and the repository's current visibility both |
| 75 | 79 | matter. The first stops a repository made public today from exposing events |
| 76 | 80 | written while it was private. The second stops a repository made private |
| @@ -0,0 +1,44 @@ | ||
| 1 | import { expect, test } from 'bun:test' | |
| 2 | import { fileURLToPath } from 'node:url' | |
| 3 | ||
| 4 | // The app preloader supplies db to ordinary requests. SSG imports the same | |
| 5 | // reader without that preloader, so test its dependency in a fresh process. | |
| 6 | // The adapter fixture performs no real database access or service startup. | |
| 7 | test('the feed reader owns its database binding without application globals', async () => { | |
| 8 | const program = ` | |
| 9 | const assert = require('node:assert/strict') | |
| 10 | const { mock } = require('bun:test') | |
| 11 | assert.equal(typeof globalThis.db, 'undefined') | |
| 12 | let reads = 0 | |
| 13 | const query = { | |
| 14 | innerJoin() { return this }, | |
| 15 | select() { return this }, | |
| 16 | where() { return this }, | |
| 17 | orderBy() { return this }, | |
| 18 | limit() { return this }, | |
| 19 | async execute() { return [] }, | |
| 20 | } | |
| 21 | mock.module('@stacksjs/database', () => ({ | |
| 22 | db: { selectFrom() { reads++; return query } }, | |
| 23 | })) | |
| 24 | const { discoverFeed } = await import('./app/Actions/Feed/read.ts') | |
| 25 | assert.deepEqual(await discoverFeed(), { entries: [], cursor: null }) | |
| 26 | assert.equal(reads, 1) | |
| 27 | assert.equal(typeof globalThis.db, 'undefined') | |
| 28 | console.log('feed database dependency resolved without globals') | |
| 29 | ` | |
| 30 | const child = Bun.spawn([process.execPath, '--no-env-file', '--config=/dev/null', '-e', program], { | |
| 31 | cwd: fileURLToPath(new URL('../..', import.meta.url)), | |
| 32 | env: { PATH: process.env.PATH }, | |
| 33 | stdout: 'pipe', | |
| 34 | stderr: 'pipe', | |
| 35 | signal: AbortSignal.timeout(5_000), | |
| 36 | }) | |
| 37 | const [output, error, code] = await Promise.all([ | |
| 38 | new Response(child.stdout).text(), | |
| 39 | new Response(child.stderr).text(), | |
| 40 | child.exited, | |
| 41 | ]) | |
| 42 | expect({ code, error }).toEqual({ code: 0, error: '' }) | |
| 43 | expect(output.trim()).toBe('feed database dependency resolved without globals') | |
| 44 | }, 10_000) | |