Skip to content

Improve error context when training entry import fails #221

Description

@KinjalGoswami68

What I noticed

I was going through runner.ts and noticed that the training entry is imported directly with:

const mod = (await import(pathToFileURL(abs).href)) as Record<
  string,
  unknown
>;
Image

The missing entry case already has a clear error message, but the import() itself isn't wrapped in any error handling.

So if the entry file exists, but something goes wrong while importing it (for example, one of its imports or dependencies is broken), the original error just bubbles up.
In that case, it may not be immediately obvious that the failure happened while loading the training entry, before the training job actually started.

What could be improved

It could be useful to add some context around the import failure, while still preserving the original error.
For example:

Failed to load training entry: <path>
Cause: <original error>

This would make it easier to understand where the failure happened without hiding the actual underlying error.

Possible approach

  • Wrap the training entry import() in a try/catch
  • Add context about which training entry failed to load
  • Preserve the original error as the cause
  • Add a test covering a failed entry import

I came across this while going through runner.ts and thought this might be worth looking into.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions