fix: enable polling in chokidar to prevent EMFILE errors on macOS (#13281)

This commit is contained in:
Tomasz Czubocha 2026-01-20 17:43:40 +00:00 committed by GitHub
parent 4496dae57d
commit 1da1bb5a02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 6 deletions

View File

@ -903,6 +903,9 @@ export class ServerlessEngineDevMode {
},
ignoreInitial: true,
followSymlinks: false,
// usePolling is enabled because chokidar v4 removed fsevents support,
// causing "EMFILE: too many open files" errors on macOS with large projects
usePolling: true,
// Add debounce to prevent rapid-fire events
awaitWriteFinish: {
stabilityThreshold: 300,

View File

@ -105,10 +105,13 @@ class AwsDev {
mainProgress.notice('Connecting')
// TODO: This should be applied more selectively
// usePolling is enabled because chokidar v4 removed fsevents support,
// causing "EMFILE: too many open files" errors on macOS with large projects
chokidar
.watch(this.serverless.config.serviceDir, {
ignored: /\.serverless/,
ignoreInitial: true,
usePolling: true,
})
.on('all', async (event, path) => {
await this.serverless.pluginManager.spawn('dev-build')
@ -751,12 +754,16 @@ class AwsDev {
this.serverless.configurationFilename,
)
chokidar.watch(configFilePath).on('change', (event, path) => {
logger.warning(
`If you've made infrastructure changes, restart the dev command w/ "serverless dev"`,
)
logger.blankLine()
})
chokidar
.watch(configFilePath, {
usePolling: true,
})
.on('change', (event, path) => {
logger.warning(
`If you've made infrastructure changes, restart the dev command w/ "serverless dev"`,
)
logger.blankLine()
})
}
/**