feat: persist the localAdoptionServer probe field#791
feat: persist the localAdoptionServer probe field#791PavelKopecky wants to merge 5 commits intomasterfrom
Conversation
WalkthroughAdds support for a nullable JSON Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/lib/override/adopted-probes.ts`:
- Around line 213-223: The format function for localAdoptionServer returns
objects with malformed expiresAt because Date.parse can be NaN and the current
check (parsedDate && parsedDate <= Date.now()) lets NaN bypass expiry; change
the expiry check in localAdoptionServer.format so that parsedDate is treated as
expired when it's not a finite number (e.g., use Number.isFinite(parsedDate) or
isFinite(parsedDate) and return null when parsedDate is non-finite or already <=
Date.now()), keeping the existing early-return conditions (value falsy or
dProbe?.userId) intact.
🧹 Nitpick comments (2)
src/probe/handler/local-adoption-server.ts (2)
1-2: Consider consolidating imports from the same module.Both
SocketProbeandLocalAdoptionServerare imported from'../types.js'. They can be combined into a single import statement.♻️ Proposed refactor
-import type { SocketProbe } from '../types.js'; -import type { LocalAdoptionServer } from '../types.js'; +import type { SocketProbe, LocalAdoptionServer } from '../types.js';
5-14: Usevalidation.valueinstead of rawdatafor assignment.Joi's
validate()may coerce or transform the input. Usingvalidation.valueensures any Joi transformations (like type coercion or default values) are applied to the stored data.♻️ Proposed fix
export const handleAdoptionServerStart = (probe: SocketProbe) => async (data: LocalAdoptionServer, callback?: (arg: string) => void) => { const validation = localAdoptionServerSchema.validate(data); if (validation.error) { callback?.('error'); throw validation.error; } - probe.localAdoptionServer = data; + probe.localAdoptionServer = validation.value; };
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/probe/handler/local-adoption-server.ts`:
- Around line 4-13: The handler handleAdoptionServerStart currently only invokes
the ack callback on validation failure; update it to also call the callback on
success so socket clients receive an acknowledgement. After setting
probe.localAdoptionServer = validation.value in handleAdoptionServerStart,
invoke callback?.('ok') (or callback?.(null) if you prefer a null/no-error
convention) so successful paths mirror the error path's acknowledgement
behavior.
🧹 Nitpick comments (1)
src/probe/handler/local-adoption-server.ts (1)
4-4:asyncis unused.The function contains no
awaitexpressions. Either removeasyncor add a brief comment if it's kept intentionally for interface consistency with other handlers.Proposed fix
-export const handleAdoptionServerStart = (probe: SocketProbe) => async (data: LocalAdoptionServer, callback?: (arg: string) => void) => { +export const handleAdoptionServerStart = (probe: SocketProbe) => (data: LocalAdoptionServer, callback?: (arg: string) => void) => {
Required for jsdelivr/globalping-dash#134