Skip to content

TypeError: Cannot read properties of undefined (reading 'replace') #766

Discussion options

You must be logged in to vote

Related issue here: kysely-org/kysely-postgres-js#60

Context is I get these errors when the database is still not ready yet. For example, when using PostgreSQL in Docker with initialization scripts, it takes a while on its first run.

In my case I just added a loop that checks if postgresql db is ready.

const pgc_ready_check = async () => {
  for (let i = 1, l = Infinity; i < l; i += 1) {
    try {
      console.log("pgc_ready_check", "#", i);
      const tables = await pgc`
        SELECT * FROM information_schema.tables;
      `;
      if (tables instanceof Array) {
        console.log("pgc_ready_check", "OK");
        return true;
      }
    } catch (e) {
      if (e instanceof Error) {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@joshxyzhimself
Comment options

Answer selected by joshxyzhimself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants