fix(server): make Brevo timeout configurable - #20
Conversation
✅ Deploy Preview for fanciful-cannoli-268c0c ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Makes the Brevo email-sending request timeout configurable via environment, with validation and example/test coverage to ensure safe parsing and defaults across environments.
Changes:
- Adds
BREVO_REQUEST_TIMEOUT_MSto server environment schema with coercion + default. - Updates
sendContactEmailto default its timeout fromenv.BREVO_REQUEST_TIMEOUT_MS. - Extends integration tests and
.env.exampleto cover configured/invalid/omitted timeout behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| server/test/contact.integration.test.ts | Adds coverage for parsing, rejecting, and defaulting the Brevo timeout env var. |
| server/src/services/email.service.ts | Uses the validated env-configured timeout as the default for Brevo requests. |
| server/src/config/env.ts | Introduces BREVO_REQUEST_TIMEOUT_MS validation + exports validateEnvironment for reuse in tests. |
| server/.env.example | Documents the new timeout setting with a default example value. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| BREVO_API_KEY: z.string().min(1, 'BREVO_API_KEY is required.'), | ||
|
|
||
| BREVO_REQUEST_TIMEOUT_MS: z.coerce.number().int().positive().default(15_000), | ||
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7af789c490
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| BREVO_API_KEY: z.string().min(1, 'BREVO_API_KEY is required.'), | ||
|
|
||
| BREVO_REQUEST_TIMEOUT_MS: z.coerce.number().int().positive().default(15_000), |
There was a problem hiding this comment.
Reject timeouts above Node's timer limit
When BREVO_REQUEST_TIMEOUT_MS is 2147483648 or larger, this schema accepts it, but Node 24 clamps an overflowing setTimeout delay to 1 ms. In the Docker runtime targeted here, such a configured value therefore aborts essentially every Brevo request immediately instead of providing a longer timeout. Add an upper bound of 2147483647 or explicitly cap the parsed value.
Useful? React with 👍 / 👎.
No description provided.