Manager: ignore small JS files
Empty (or almost-empty) JS files are ignored by the job compiler.
This commit is contained in:
parent
7a89c07fc9
commit
89fdc45b45
@ -49,6 +49,14 @@ func (s *Service) loadScriptsFrom(filesystem fs.FS) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(script_bytes) < 8 {
|
||||
log.Debug().
|
||||
Str("script", filename).
|
||||
Int("fileSizeBytes", len(script_bytes)).
|
||||
Msg("ignoring tiny JS file, it is unlikely to be a job compiler script")
|
||||
continue
|
||||
}
|
||||
|
||||
program, err := goja.Compile(filename, string(script_bytes), true)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Str("filename", filename).Msg("failed to compile script")
|
||||
|
@ -25,6 +25,7 @@ func TestLoadScriptsFrom_on_disk_js(t *testing.T) {
|
||||
expectKeys := map[string]bool{
|
||||
"echo-and-sleep": true,
|
||||
"simple-blender-render": true,
|
||||
// Should NOT contain an entry for 'empty.js'.
|
||||
}
|
||||
assert.Equal(t, expectKeys, keys(s.compilers))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user