Bug Summary
In backend/services/eventService.js, the listEvents function calls eventCrud.list() with no filter, sort limit, or pagination parameters:
const listEvents = async () => eventCrud.list();
This fetches every event document from MongoDB in a single query. As the event collection grows (past events, recurring events, archived records), this endpoint returns an ever-increasing payload, eventually exhausting available memory and causing response timeouts.
Steps to Reproduce
- Insert a large number of event documents (e.g., 5000) into the database.
- Call
GET /api/events (or the frontend page that triggers this service).
- Observe the response time increase linearly with document count.
- With enough documents, the endpoint times out or causes an out-of-memory crash.
Expected Behavior
The endpoint should apply a default limit and support pagination. The donation.controller.js in the same project already demonstrates the correct pattern:
const listEvents = async ({ page = 1, limit = 20, filter = {}, sort = { schedule: -1 } } = {}) => {
return eventCrud.list({ filter, sort, skip: (page - 1) * limit, limit });
};
Actual Behavior
All events are fetched unconditionally. Unlike upcomingEvents which uses a date filter and getCampaigns which paginates, listEvents has no upper bound.
Environment
- Backend: Node.js / Express / Mongoose
- File:
backend/services/eventService.js, function: listEvents
Additional Context
Expected NSOC points: NSOC'26 level2 (medium complexity - unbounded database query causing performance degradation)
Suggested labels: bug, NSOC'26, level2
Checklist:
Bug Summary
In
backend/services/eventService.js, thelistEventsfunction callseventCrud.list()with no filter, sort limit, or pagination parameters:This fetches every event document from MongoDB in a single query. As the event collection grows (past events, recurring events, archived records), this endpoint returns an ever-increasing payload, eventually exhausting available memory and causing response timeouts.
Steps to Reproduce
GET /api/events(or the frontend page that triggers this service).Expected Behavior
The endpoint should apply a default limit and support pagination. The
donation.controller.jsin the same project already demonstrates the correct pattern:Actual Behavior
All events are fetched unconditionally. Unlike
upcomingEventswhich uses a date filter andgetCampaignswhich paginates,listEventshas no upper bound.Environment
backend/services/eventService.js, function:listEventsAdditional Context
Expected NSOC points: NSOC'26 level2 (medium complexity - unbounded database query causing performance degradation)
Suggested labels:
bug,NSOC'26,level2Checklist: