Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an error if keystone.connect not called before queries made #1081

Closed
jesstelford opened this issue May 3, 2019 · 2 comments
Closed

Comments

@jesstelford
Copy link
Contributor

jesstelford commented May 3, 2019

Within a server.js file, it's possible to do this:

const keystone = require('@keystone-alpha/core');

keystone
  .prepare({ port })
  .then(async ({ server, keystone: keystoneApp }) => {
    await server.start();
  })
  .catch(error => {
    console.error(error);
    process.exit(1);
  });

If you've got auth enabled, you'll then be able to see the Admin login page just fine, but wont be able to login.

Can you spot the error?

const keystone = require('@keystone-alpha/core');

keystone
  .prepare({ port })
  .then(async ({ server, keystone: keystoneApp }) => {

    await keystoneApp.connect(); // Whoops, we forgot this line!

    await server.start();
  })
  .catch(error => {
    console.error(error);
    process.exit(1);
  });

We should throw an error (or warning?) if server.start() is called before keystone.connect() is called.

Or possibly throw the warning if any requests are made to any routes before keystone.connect is called.

@jesstelford jesstelford added the dx label May 3, 2019
@jesstelford jesstelford changed the title Throw an error if keystone.connect not called before server.start Throw an error if keystone.connect not called before queries made May 30, 2019
@jesstelford
Copy link
Contributor Author

This has changed slightly since the new Custom Servers don't have keystone.start() anymore, but the problem persists: making queries before keystone.connect() has complete should throw an error about not being connected.

@stale
Copy link

stale bot commented Feb 7, 2020

It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :)

@stale stale bot added the needs-review label Feb 7, 2020
@stale stale bot closed this as completed Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants