question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection events

See original GitHub issue

Feature request

It would be great to have some way to monitor connection events for reporting purposes and to setup defaults for the connection. For example, in Node I would run:

dbPool.on("connect", (client: PoolClient) => {
  if (ENV.TEST) {
    // Prefer indexes even on small tables. This disables optimizations in PostgreSQL that 
    // prefers scanning small tables, thus changing how EXPLAIN works between test and prod environments. 
    // @see: https://www.postgresql.org/docs/9.4/static/runtime-config-query.html#GUC-ENABLE-SEQSCAN
    client.query(`SET enable_seqscan = OFF;`);
  }
});

I don’t see a similar way to do this in the Deno driver.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Soremwarcommented, Mar 5, 2021

I’m not to keen to integrate uncontrollable async behaviour such as the EventEmitter style you are proposing

I find @ebebbington solution much more reliable for the current use case, and could be roughly translated to the following

export const getTestClient = async () => {
  const client = await pool.connect();
  if (Deno.env.get("TEST") === "true") {
    await client.queryArray`SET enable_seqscan = OFF`;
  }
  return client;
}
0reactions
Soremwarcommented, Sep 29, 2021

Closing due to inactivity

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection Events – Organizer of International Business ...
Connection Events designs services and solutions for professionals in the videogame and the visual effects industries. OUR EVENTS ...
Read more >
Connection Events - LinkedIn
Connection Events creates opportunities for international development and is supported by a network of high-profile market players from every segment of the ...
Read more >
Connection Events - ADO.NET - Microsoft Learn
NET Framework data providers have Connection objects with two events that you can use to retrieve informational messages from a data source ...
Read more >
Responding to Connection Events - IBM
These events include information about new and existing connections to a structure (including failed-persistent connections), operations to rebuild a structure, ...
Read more >
AWS::Events::Connection - AWS CloudFormation
Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found