Skip to content

Commit

Permalink
debug: Add logging before/after transit route's socket calls
Browse files Browse the repository at this point in the history
While investigating #1011, we add logging in the trRouting's socket
calls, to see if the callback is called by the server and received by
teh caller.
  • Loading branch information
tahini committed Sep 13, 2024
1 parent 657976c commit f17d2e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,13 @@ export class TrRoutingService {
params: TrRoutingApi.TransitRouteQueryOptions,
hostPort?: TrRoutingApi.HostPort
): Promise<TrRoutingRouteResult> {
const origDestStr = `${params.originDestination[0].geometry.coordinates.join(',')} to ${params.originDestination[1].geometry.coordinates.join(',')}`;
console.log(`tripRouting: Getting route from trRouting service for ${origDestStr}`);
const responseStatus = await this.callTrRouting<
{ parameters: TrRoutingApi.TransitRouteQueryOptions; hostPort?: TrRoutingApi.HostPort },
TrRoutingApi.TrRoutingV2.RouteResponse
>(apiCalls.route, { parameters: params, hostPort });
console.log(`tripRouting: Received route response from trRouting service for ${origDestStr}`);
if (Status.isStatusError(responseStatus)) {
this.handleErrorStatus(responseStatus);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/transition-backend/src/api/services.socketRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,20 @@ export default function (socket: EventEmitter, userId?: number) {
});

socket.on(TrRoutingConstants.ROUTE, async ({ parameters, hostPort }, callback) => {
const origDestStr = `${parameters.originDestination[0].geometry.coordinates.join(',')} to ${parameters.originDestination[1].geometry.coordinates.join(',')}`;
try {
console.log(`tripRouting: Received route request from socket route for ${origDestStr}`);
const routingResults = await trRoutingService.route(parameters, hostPort);
callback(Status.createOk(routingResults));
console.log(
`tripRouting: Called callback after successful route request from socket route for ${origDestStr}`
);
} catch (error) {
console.error(error);
callback(Status.createError(TrError.isTrError(error) ? error.message : error));
console.log(
`tripRouting: Called callback after erroneous route request from socket route for ${origDestStr}`
);
}
});

Expand Down

0 comments on commit f17d2e1

Please sign in to comment.