Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add error message if unable to find cron expression for schedule…
…d function (#1123) * fix: add error message if cron expression not found or invalid in isc of scheduled funcs
- Loading branch information
1 parent
7e21b63
commit 2309f4b
Showing
6 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/fixtures/in-source-config/functions/cron_esm_additional_schedule_import.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { schedule as nfySchedule } from '@netlify/functions' | ||
import { schedule } from '../node_modules/@netlify/functions/index.js' | ||
// make sure cron expression is found/doesn't error if `schedule` is also imported from another source | ||
|
||
schedule() | ||
|
||
export const handler = nfySchedule('@daily', () => { | ||
// function handler | ||
}) |
5 changes: 5 additions & 0 deletions
5
...es/in-source-config/functions_missing_cron_expression/cron_cjs_invalid_cron_expression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { schedule } = require('@netlify/functions') | ||
|
||
module.exports.handler = schedule(null, () => { | ||
// function handler | ||
}) |
4 changes: 4 additions & 0 deletions
4
...xtures/in-source-config/functions_missing_cron_expression/cron_cjs_schedule_not_called.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const { schedule } = require('@netlify/functions') | ||
|
||
// Should throw an error that `schedule` is imported but cron expression not found | ||
module.exports.handler = {} |
5 changes: 5 additions & 0 deletions
5
...xtures/in-source-config/functions_missing_cron_expression/cron_esm_schedule_not_called.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line n/no-unsupported-features/es-syntax | ||
import { schedule } from '@netlify/functions' | ||
|
||
// Should throw an error that schedule is imported but cron expression not found | ||
export const handler = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2309f4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏱ Benchmark results
largeDepsEsbuild: 7s
largeDepsNft: 33.4s
largeDepsZisi: 50.6s