Skip to content

Commit

Permalink
Merge pull request #2964 from OpenNeuroOrg/fix/handle-worker-restarts
Browse files Browse the repository at this point in the history
fix(api): Prevent crash when tree is requested with no children
  • Loading branch information
nellh authored Jan 4, 2024
2 parents 34d3991 + 06f7061 commit 595896d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/openneuro-server/src/handlers/datalad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const getFile = async (req, res) => {
if (level == pathComponents.slice(-1)) {
file = files.find((f) => !f.directory && f.filename === level)
} else {
tree = files.find((f) => f.directory && f.filename === level).id
// This tree may exist but have no children
if (files) {
tree = files.find((f) => f.directory && f.filename === level).id
}
}
} catch (err) {
// ConnectTimeoutError is Node/Undici and TimeoutError is the standard DOMException name
Expand Down

0 comments on commit 595896d

Please sign in to comment.