Skip to content

refactor: correct loop syntax for synchronous iterations #787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/examples/server/simpleSseServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ process.on('SIGINT', async () => {
console.log('Shutting down server...');

// Close all active transports to properly clean up resources
for (const sessionId in transports) {
for await (const sessionId of Object.keys(transports)) {
try {
console.log(`Closing transport for session ${sessionId}`);
await transports[sessionId].close();
Expand Down
2 changes: 1 addition & 1 deletion src/examples/server/simpleStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ process.on('SIGINT', async () => {
console.log('Shutting down server...');

// Close all active transports to properly clean up resources
for (const sessionId in transports) {
for await (const sessionId of Object.keys(transports)) {
try {
console.log(`Closing transport for session ${sessionId}`);
await transports[sessionId].close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ process.on('SIGINT', async () => {
console.log('Shutting down server...');

// Close all active transports to properly clean up resources
for (const sessionId in transports) {
for await (const sessionId of Object.keys(transports)) {
try {
console.log(`Closing transport for session ${sessionId}`);
await transports[sessionId].close();
Expand Down
2 changes: 1 addition & 1 deletion src/examples/shared/inMemoryEventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class InMemoryEventStore implements EventStore {
// Sort events by eventId for chronological ordering
const sortedEvents = [...this.events.entries()].sort((a, b) => a[0].localeCompare(b[0]));

for (const [eventId, { streamId: eventStreamId, message }] of sortedEvents) {
for await (const [eventId, { streamId: eventStreamId, message }] of sortedEvents) {
// Only include events from the same stream
if (eventStreamId !== streamId) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/server/auth/middleware/allowedMethods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("allowedMethods", () => {
test("returns 405 for unspecified HTTP methods", async () => {
const methods = ["post", "put", "delete", "patch"];

for (const method of methods) {
for await (const method of methods) {
// @ts-expect-error - dynamic method call
const response = await request(app)[method]("/test");
expect(response.status).toBe(405);
Expand Down
2 changes: 1 addition & 1 deletion src/server/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export class McpServer {
);

const templateResources: Resource[] = [];
for (const template of Object.values(
for await (const template of Object.values(
this._registeredResourceTemplates,
)) {
if (!template.resourceTemplate.listCallback) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/streamableHttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ describe("StreamableHTTPServerTransport with resumability", () => {
const streamId = lastEventId.split('_')[0];
// Extract stream ID from the event ID
// For test simplicity, just return all events with matching streamId that aren't the lastEventId
for (const [eventId, { message }] of storedEvents.entries()) {
for await (const [eventId, { message }] of storedEvents.entries()) {
if (eventId.startsWith(streamId) && eventId !== lastEventId) {
await send(eventId, message);
}
Expand Down