Skip to content

[Bug] Reference Errors and Broken Function Scoping in Offline Sync Service #3583

Description

@Sandeep6135

Description

The syncService.js script contains multiple reference errors and syntax issues:

  1. Undefined Functions: syncAttendanceQueue calls getOutboxRecords(), removeFromOutbox(), and getAuth(), none of which are imported or declared in the module scope.
  2. Duplicate ESM Exports: registerBackgroundSync is declared and exported twice (at lines 164 and 211).
  3. Stray Module Code: A block of queue flushing logic resides directly in the module body and ends with a stray closing brace }, causing compilation errors.

Code Location

  • File: lib/syncService.js
// Line 120, 144, and 124
const records = await getOutboxRecords(); // ReferenceError
await removeFromOutbox(records[i].id);    // ReferenceError
const auth = getAuth();                   // ReferenceError

Impact

The offline synchronization script cannot compile, preventing offline PWA data from successfully synchronizing back to the database when connectivity is restored.

Recommended Fix

  • Clean up the bottom of the file by removing duplicate exports.
  • Map getOutboxRecords to getPendingActions and removeFromOutbox to removePendingAction (which are already imported).
  • Import the initialized auth client directly from @/lib/firebaseConfig.

Metadata

Metadata

Assignees

Labels

GSSoC'26Part of GirlScript Summer of Code 2026bugSomething isn't workingmentor:Ayushh-SharmaaGSSoC: Mentor — @Ayushh-Sharmaa

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions