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

Fix startup crash when a non-superuser tries to watch #371

Merged
merged 3 commits into from
Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/postgraphql/watch/__tests__/watchPgSchemas-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ test('will log some stuff and continue if the watch fixtures query fails', async
await watchPgSchemas({ pgPool })
console.warn = origWarn
expect(pgPool.connect.mock.calls).toEqual([[]])
expect(pgClient.query.mock.calls).toEqual([[await _watchFixturesQuery], ['listen postgraphql_watch']])
expect(pgClient.query.mock.calls).toEqual([
[await _watchFixturesQuery],
['rollback'],
['listen postgraphql_watch'],
])
expect(pgClient.on.mock.calls.length).toBe(1)
expect(pgClient.on.mock.calls[0].length).toBe(2)
expect(pgClient.on.mock.calls[0][0]).toBe('notification')
Expand Down
1 change: 1 addition & 0 deletions src/postgraphql/watch/watchPgSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default async function watchPgSchemas ({ pgPool, pgSchemas, onChange }: {
console.warn(chalk.yellow('This is likely because your Postgres user is not a superuser. If the'))
console.warn(chalk.yellow('fixtures already exist, the watch functionality may still work.'))
// tslint:enable no-console
await pgClient.query('rollback')
}

// Listen to the `postgraphql_watch` channel. Any and all updates will come
Expand Down