Skip to content

Commit

Permalink
Merge pull request #31 from planetscale/iheanyi/throw-error-from-refresh
Browse files Browse the repository at this point in the history
Do not swallow errors from refreshing
  • Loading branch information
iheanyi authored Aug 11, 2022
2 parents 2e6fb30 + 2cca3ee commit 52e73b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
3 changes: 1 addition & 2 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ describe('refresh', () => {
test('it sets the session variable when true', async () => {
const connection = connect(config)
mockPool.intercept({ path: CREATE_SESSION_PATH, method: 'POST' }).reply(200, JSON.stringify(mockSession))
const got = await connection.refresh()
expect(got).toEqual(true)
await connection.refresh()
})
})

Expand Down
9 changes: 2 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ export class Connection {
}
}

async refresh(): Promise<boolean> {
try {
await this.createSession()
return true
} catch {
return false
}
async refresh(): Promise<void> {
await this.createSession()
}

private async createSession(): Promise<QuerySession> {
Expand Down

0 comments on commit 52e73b2

Please sign in to comment.