Skip to content

Commit

Permalink
fix: pre- and post-handler execution in NanotronApiServer
Browse files Browse the repository at this point in the history
Co-authored-by: S. Amir Mohammad Najafi <[email protected]>
  • Loading branch information
alimd and njfamirm committed Oct 16, 2024
1 parent f8efcbf commit ec3b4b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/api-server/src/api-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ export class NanotronApiServer {

try {
for (const handler of routeOption.preHandlers) {
if (connection.terminatedHandlers === true) return;
await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);
if (connection.terminatedHandlers === true) return; // must check after each pre-handler.
}

await routeOption.handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);

for (const handler of routeOption.postHandlers) {
if (connection.terminatedHandlers === true) return;
if (connection.terminatedHandlers === true) return; // must check before each post-handler.
await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);
}
}
Expand Down

0 comments on commit ec3b4b9

Please sign in to comment.