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(listen): makes sure unlisten returns a reference to conn result #160

Merged
merged 2 commits into from
Mar 16, 2021

Conversation

stalniy
Copy link
Contributor

@stalniy stalniy commented Mar 9, 2021

Eventually, this allows to get the new pid of pg connection after listen reconnects.

Follow up PR for #155
Issue in tests: how can I test unequality in tests?

t('listen result reports correct connection state after reconnection', async() => {
  const listener = postgres(options)
      , xs = []

  const result = await listener.listen('test', x => xs.push(x))
  const initialPid = result.state.pid
  await sql.notify('test', 'a')
  await sql`select pg_terminate_backend(${ initialPid }::int)`
  await delay(50)
  listener.end()

  return [result.state.pid, initialPid]
})

Eventually, this allows to get the new pid of pg connection after `listen` reconnects
@porsager
Copy link
Owner

Cool @stalniy !

To test inequality you can simply do [this !== that, true]

@stalniy
Copy link
Contributor Author

stalniy commented Mar 10, 2021

right! So simple :)

@stalniy
Copy link
Contributor Author

stalniy commented Mar 16, 2021

@porsager any plans to merge and release this?

@porsager
Copy link
Owner

Ah, sorry. Didn't see your latest changes. Looks good.

@porsager porsager merged commit c3b6531 into porsager:master Mar 16, 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

Successfully merging this pull request may close these issues.

2 participants