Skip to content

1.2.0 database issue test#25

Closed
joshuasorkin wants to merge 6 commits intoproductionfrom
1.2.0-database-issue-test
Closed

1.2.0 database issue test#25
joshuasorkin wants to merge 6 commits intoproductionfrom
1.2.0-database-issue-test

Conversation

@joshuasorkin
Copy link
Copy Markdown
Owner

I resolved the issue regarding database singleton instantiation. Basically, the constructor was never getting called. I followed the pattern for an ES6 singleton as described in : https://code.tutsplus.com/tutorials/how-to-implement-the-singleton-pattern-in-javascript-es6--cms-39927

Also made a few changes to sms.js because it was failing during testing, but I'll stop there and do the rest of that work on a different branch once we merge this one.

Copy link
Copy Markdown
Contributor

@minademian minademian left a comment

Choose a reason for hiding this comment

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

Tested the branch locally with a fresh ngrok URL. The phone call flow still doesn’t work.

  • no database errors in console, still reports: "Database connection established successfully."
  • 403 error on /voice API call in Twilio errors

When I turned off request validation for the /voice API call (passing {validate: false}) and tested the phone call flow again, I got the following error in the console:

/voice: callSid: CAec2c41d72d724072b9f30a02c8efce8f
Executing (default): select * from worker where contact_uri='+46736455849'
contact_uriExists: workerSid CAab6f4359b5f4c8f0feb8aaebfea77777
workerSid!=null: true
updateWorkerActivity: getting workerSid from database
Executing (default): select * from worker where contact_uri='+46736455849'
updateWorkerActivity: workerSid is CAab6f4359b5f4c8f0feb8aaebfea77777
updateWorkerFromSid: error updating worker activity: Error: The requested resource /Workspaces/WS61afa2202c9adfbb4a245f6bc3c8495c/Workers/CAab6f4359b5f4c8f0feb8aaebfea77777 was not found
updateWorkerFromSid error: TypeError: Cannot read properties of undefined (reading 'activityName')
/Users/minademian/code/vent-taskrouter/src/lib/worker.js:83
        workerEntity.friendlyName
                     ^

TypeError: Cannot read properties of undefined (reading 'friendlyName')
    at Worker.updateWorkerActivity (/Users/minademian/code/vent-taskrouter/src/lib/worker.js:83:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/minademian/code/vent-taskrouter/src/server.js:411:20
[nodemon] app crashed - waiting for file changes before starting...

Comment thread src/config/database.js
if (!this._instance){
this._instance = new Database();
}
return this._instance;
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.

not sure how this would work in theory - static methods don’t have access to this, they’re class methods. this refers to instance methods...

@joshuasorkin
Copy link
Copy Markdown
Owner Author

all changes in this PR are included in either #16 or #28, going to close it

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