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

When used with seneca-entity, await-ing on seneca.make$ is not awaited on #18

Open
lilsweetcaligula opened this issue Mar 23, 2023 · 1 comment

Comments

@lilsweetcaligula
Copy link

The following can be reproduced by using many stores, but in this example we're using seneca-knex-store against a postgres instance. Before you can run the code, create the racers table:

CREATE TABLE racers (
  id VARCHAR(36) NOT NULL,
  username VARCHAR(255) NOT NULL,
  favorite_car VARCHAR(255) NOT NULL,

  PRIMARY KEY (id),
  UNIQUE(username)
);
        const configDB = {
          // some code here
        }

	const seneca = Seneca()
		.test()
		.use('promisify')
		.use('entity', { mem_store: false })
		.use('seneca-knex-store', configDB)

	await seneca.ready()

	await seneca.make$('racers')
		.save$({
			username: 'Jose',
			favorite_car: 'Ferrari'
		})

	throw new Error('Oops!')

	await seneca.make$('racers')
		.save$({
			username: 'Leo',
			favorite_car: 'Lamborghini'
		})

After running the code, inspection of the database with psql shows that no racers were created, which means the first call to .save$ was not properly awaited on.

Replacing seneca.make$ with seneca.entity does fix this issue, but it would be nice (and less surprising) if seneca.make$ worked as well.

@rjrodger
Copy link
Contributor

ah - sadly this can't be fixed as seneca.make$ must remain backward compatible and hence does not return Promise enabled entities

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