Skip to content

Handle startup errors and harden notes loading#8

Merged
ni0520 merged 3 commits intomainfrom
codex/check-and-fix-all-error-messages
Feb 19, 2026
Merged

Handle startup errors and harden notes loading#8
ni0520 merged 3 commits intomainfrom
codex/check-and-fix-all-error-messages

Conversation

@ni0520
Copy link
Owner

@ni0520 ni0520 commented Feb 19, 2026

Motivation

  • Prevent application crashes and confusing errors when notes.json contains invalid data.
  • Provide a clear, actionable message and graceful exit when the configured port is already in use.

Description

  • Hardened notes loading by parsing notes.json into parsedNotes and using notes = Array.isArray(parsedNotes) ? parsedNotes : [] to ensure notes is always an array.
  • Replaced app.listen(...) with a server object and added an error handler that specifically checks for EADDRINUSE, logs a clear instruction, and exits with code 1.
  • All other behaviors (routes and note persistence via saveNotes) are preserved.

Testing

  • Confirmed node is present with node -v and started the app using node index.js, then validated routes returned 200 for /, /notes, and /notes/new using curl.
  • Performed a POST to /notes and observed a 302 redirect to confirm note creation flow.
  • Simulated a port collision by launching a second instance and verified the second process logs Port 3000 is already in use... and exits with status 1.

Codex Task

@vercel
Copy link
Contributor

vercel bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code Ready Ready Preview, Comment Feb 19, 2026 8:58am
code-nq2m Ready Ready Preview, Comment Feb 19, 2026 8:58am

@ni0520
Copy link
Owner Author

ni0520 commented Feb 19, 2026

Ok

Copy link
Owner Author

@ni0520 ni0520 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@ni0520 ni0520 merged commit 1b0cfbf into main Feb 19, 2026
6 checks passed
@ni0520 ni0520 deleted the codex/check-and-fix-all-error-messages branch February 19, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Done

1 participant