Skip to content

A refused schema registration is an unhandled rejection that ends ajs project dev, not a failure of the queries on that schema #61

Closed

Description

@Upd4ting

docs/external-mode.md of @antelopejs/rethinkdb says that when registration fails, "every query on it fails with the same message", and its README says schema initialization "refuses" a table that declares a unique index. The module does reject: Schemas.register throws and registerExternal keeps the failure in the schema's gate.

The consumer's new Schema(id, definition) (interface-database dist/schema.js) calls Schemas.register(...) and drops its promise, so the rejection reaches core as Unhandled rejection: Error: Table 'bad.ghost' reads table ghost, which database erp does not have, and ajs project dev exits with code 1 before any query is made. A query can never fail with that message in a running project.

Reproduction: an external instance (mode: "external"), new Schema("bad", { ghost: { fields: { a: "string" }, indexes: {} } }) in a consumer module under ajs project dev. The same happens for a unique secondary index in owned mode, an _id over keys of two types and an unknown field type.

Fix idea: either keep the registration promise on the Schema (so createInstance/queries reject with it, as the docs say) and handle the rejection, or reword the docs to say the project stops with the message. The verification skill of the rethinkdb V5 PR pins the message in the run's logs and the process exit, not a failing query.

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