Skip to content
Open
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 hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ class HANAService extends SQLService {
service.server.major = dbc.server.major || service.server.major
return dbc
} catch (err) {
if (err.code === 10) return // authentication error, see error handler below
if (err.code === 10) {
// authentication error
LOG.debug('connection failed:', err)
throw new Error(`Pool failed connecting`, { cause: err })
}
if (attempt < maxRetries) {
Comment on lines +62 to 67

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (err.code === 10) {
// authentication error
LOG.debug('connection failed:', err)
throw new Error(`Pool failed connecting`, { cause: err })
}
if (attempt < maxRetries) {
if (err.code !== 10 && attempt < maxRetries) {

I think the error just needs to bubble up. There's no need to log or wrap it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works except for the initial connection when starting a CAP app. There the proposed change will throw:
"[queue] - Failed to fetch targets for flush Error: Pool resource could not be acquired within 10s"
For requests that are after that hitting the service it will correctly show: "[odata] - 500 - SqlError {message: "authentication failed..."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a new PR that has a better behavior: #1684. This should include the db error in the response and log.

LOG.debug('connection failed:', err, '- retrying attempt', attempt, 'of', maxRetries)
return createSingleTenant(tenant, attempt + 1)
Expand Down