Skip to content

Commit 2b2958d

Browse files
authored
fix devvit logs (#15)
<!-- If this pull request closes an issue, please mention the issue number below --> Closes # <!-- Issue # here --> ## 💸 TL;DR <!-- What's the three sentence summary of purpose of the PR --> I gave llms too much power and it kept messing up stuff. Also, since is required because we only stream this from the logs and I need to stop it forcibly since we need a more rest styled request. ## 📜 Details [Design Doc](<!-- insert Google Doc link here if applicable -->) [Jira](<!-- insert Jira link if applicable -->) <!-- Add additional details required for the PR: breaking changes, screenshots, external dependency changes --> ## 🧪 Testing Steps / Validation <!-- add details on how this PR has been tested, include reproductions and screenshots where applicable --> ## ✅ Checks <!-- Make sure your pr passes the CI checks and do check the following fields as needed - --> - [ ] CI tests (if present) are passing - [ ] Adheres to code style for repo - [ ] Contributor License Agreement (CLA) completed if not a Reddit employee
1 parent 41a2f21 commit 2b2958d

3 files changed

Lines changed: 22 additions & 39 deletions

File tree

package-lock.json

Lines changed: 9 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"check": "npm run lint && npm run type-check && npm run prettier",
1919
"clean": "rm -rf ./dist ./fixtures ./db ./fixtures.tar.gz",
2020
"dev": "concurrently -p \"[{name}]\" -n \"ESBUILD,INSPECTOR\" -c \"blue,green\" \"npm run build:watch\" \"npm run dev:inspector\"",
21-
"dev:inspector": "npx @modelcontextprotocol/inspector node ./dist/index.js",
21+
"dev:inspector": "npx --yes @modelcontextprotocol/inspector@0.14.3 node ./dist/index.js",
2222
"lint": "eslint ./src",
2323
"lint:fix": "eslint --fix ./src",
2424
"prepare": "npm run check && npm run type-check && npm run build",
@@ -30,7 +30,7 @@
3030
"type-check": "tsc --noEmit"
3131
},
3232
"dependencies": {
33-
"@modelcontextprotocol/sdk": "1.11.0",
33+
"@modelcontextprotocol/sdk": "1.17.3",
3434
"@xenova/transformers": "2.17.2",
3535
"archiver": "^6.0.2",
3636
"better-sqlite3": "11.9.1",

src/tools/logs.ts

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,17 @@ This is a convenience wrapper around the \`devvit logs\` CLI command. Supply a s
1212
1313
Examples:
1414
{ subreddit: "mySubreddit" }
15-
{ subreddit: "r/myTestSubreddit", app: "my-app", json: true, since: "15m" }`,
15+
{ subreddit: "r/myTestSubreddit", app: "my-app", since: "15m" }`,
1616
inputSchema: z.object({
1717
subreddit: z.string().describe('Provide the subreddit name. The "r/" prefix is optional'),
18+
since: z.string().describe('Start time for logs (e.g. "15s", "2w1d", "30m").'),
1819
app: z.string().optional().describe('Provide the app name'),
19-
config: z.string().optional().describe('Path to devvit config file (default: devvit.yaml)'),
20-
connect: z.boolean().optional().default(false).describe('Connect to local runtime'),
21-
dateformat: z
22-
.string()
23-
.optional()
24-
.describe(
25-
'Format for rendering dates (default: "MMM d HH:mm:ss"). See https://date-fns.org/docs/format for formatting options.'
26-
),
27-
json: z.boolean().optional().default(false).describe('Output JSON for each log line'),
28-
since: z
29-
.string()
30-
.optional()
31-
.describe('Start time for logs (e.g. "15s", "2w1d", "30m"). Defaults to 0m (now)'),
32-
verbose: z.boolean().optional().default(true).describe('Enable verbose output'),
20+
config: z.string().optional().describe('Path to devvit config file (default: devvit.json)'),
3321
}),
3422
handler: async ({ params }) => {
35-
const { subreddit, app, config, connect, dateformat, json: jsonFlag, since, verbose } = params;
23+
const { subreddit, app, config, since } = params;
3624

37-
const args: string[] = ['logs', subreddit];
25+
const args: string[] = ['devvit', 'logs', subreddit];
3826
const repoRoot = resolveRepoRoot();
3927

4028
if (!repoRoot && !params.app) {
@@ -53,16 +41,12 @@ Examples:
5341

5442
// Flags ---------------------------------------------------------------
5543
if (config) args.push('--config', config);
56-
if (connect) args.push('--connect');
57-
if (dateformat) args.push('--dateformat', dateformat);
58-
if (jsonFlag) args.push('--json');
59-
if (since) args.push('--since', since);
60-
if (verbose) args.push('--verbose');
44+
args.push('--since', since);
6145

6246
logger.info(`🚀 Executing: devvit ${args.join(' ')}`);
6347

6448
return await new Promise((resolve) => {
65-
const child = spawn('devvit', args, {
49+
const child = spawn('npx', args, {
6650
stdio: ['ignore', 'pipe', 'pipe'],
6751
env: process.env,
6852
cwd: repoRoot,
@@ -96,10 +80,12 @@ Examples:
9680
});
9781
});
9882

99-
const KILL_TIMEOUT_MS = 2_000; // Prevent indefinite hanging by killing process after 10s
83+
const KILL_TIMEOUT_MS = 4_000; // Prevent indefinite hanging by killing process after 4s
10084

10185
const timeout = setTimeout(() => {
102-
logger.info(`⌛ Reached timeout (${KILL_TIMEOUT_MS}ms) – terminating devvit logs process…`);
86+
logger.error(
87+
`⌛ Reached timeout (${KILL_TIMEOUT_MS}ms) – terminating devvit logs process…`
88+
);
10389
child.kill('SIGINT');
10490
}, KILL_TIMEOUT_MS);
10591

0 commit comments

Comments
 (0)