Debugging Node.js express app - node.js

TypeError: Cannot call method 'get' of undefined
at C:\Users\denman\workspace-nodejs\ExpressNodeUpAndRunning\app.js:112:25
I am trying to find out the line number of the error...
is 112 the line number of the app.js file where the error occurred? Then what is 25?

The 3 components are sourceFilePath:lineNumber:columnNumber.
So the error occurs on line 112, at column 25.

Related

Python Firestore insert return error 503 DNS resolution failed

I have a problem during the execution of my python script from crontab, which consists of an insert operation in the firestore database.
db.collection(u'ab').document(str(row["Name"])).collection(str(row["id"])).document(str(row2["id"])).set(self.packStructure(row2))
When I execute normally with python3 script.py command it works, but when I execute it from crontab it return the following error:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/axatel/angel_bridge/esportazione_firebase/main.py", line 23, in <module>
dato.getDati(dato, db, cursor, cursor2, fdb, select, anagrafica)
File "/home/axatel/angel_bridge/esportazione_firebase/dati.py", line 19, in getDati
db.collection(u'ab').document(str(row["Name"])).collection(str(row["id"])).document(str(row2["id"])).set(self.packStructure(row2))
File "/home/axatel/.local/lib/python3.7/site-packages/google/cloud/firestore_v1/document.py", line 234, in set
write_results = batch.commit()
File "/home/axatel/.local/lib/python3.7/site-packages/google/cloud/firestore_v1/batch.py", line 147, in commit
metadata=self._client._rpc_metadata,
File "/home/axatel/.local/lib/python3.7/site-packages/google/cloud/firestore_v1/gapic/firestore_client.py", line 1121, in commit
request, retry=retry, timeout=timeout, metadata=metadata
File "/home/axatel/.local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "/home/axatel/.local/lib/python3.7/site-packages/google/api_core/retry.py", line 286, in retry_wrapped_func
on_error=on_error,
File "/home/axatel/.local/lib/python3.7/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/home/axatel/.local/lib/python3.7/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "/home/axatel/.local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.ServiceUnavailable: 503 DNS resolution failed for service: firestore.googleapis.com:443
I really don't understand what's the problem, because the connection at the database works every time the script is started in both ways.
Is there a fix for this kind of issue?
I found something that might be helpful. There is nice troubleshooting guide and there is a part there, which seems to be related:
If your command works by invoking a runtime like python some-command.py perform a few checks to determine that the runtime
version and environment is correct. Each language runtime has quirks
that can cause unexpected behavior under crontab.
For python you might find that your web app is using a virtual
environment you need to invoke in your crontab.
I haven't seen such error running Firestore API, but this seems to match to your issue.
I found the solution.
The problem occured because the timeout sleep() value was lower than expected, so the database connection function starts too early during boot phase of machine. Increasing this value to 45 or 60 seconds fixed the problem.
#time.sleep(10) # old version
time.sleep(60) # working version
fdb = firebaseConnection()
def firebaseConnection():
# firebase connection
cred = credentials.Certificate('/database/axatel.json')
firebase_admin.initialize_app(cred)
fdb = firestore.client()
if fdb:
return fdb
else:
print("Error")
sys.exit()

Local stack says started but throwing different errors `Error forwarding request: TypeError: the JSON object must be str, bytes or bytearray

I am getting this when I start make infra using localstack
Starting local dev environment. CTRL-C to quit.
cannot import name 'dns_server' from 'localstack_ext.services' (unknown location)
Starting mock S3 (http port 4572)...
Starting mock SNS (http port 4575)...
2019-09-21T13:11:08:INFO:localstack.multiserver: Starting multi API server process on port
51492
Starting mock SQS (http port 4576)...
Starting mock DynamoDB (http port 4569)...
Starting mock Lambda service (http port 4574)...
Starting mock CloudWatch Logs (http port 4586)...
Ready.
But when I do http://localhost:4569 it throws error and doesnt show it started.
Below are the errors I am getting
2019-09-21T13:15:05:ERROR:localstack.services.generic_proxy: Error forwarding request: the
JSON object must be str, bytes or bytearray, not NoneType Traceback (most recent call last):
File "/Users//workspaces/others/localstack/localstack/services/generic_proxy.py", line 240,
in forward
path=path, data=data, headers=forward_headers)
File"/Users//workspaces/others/localstack/localstack/services/dynamodb/dynamodb_listener.py",
line 35, in forward_request
data = json.loads(to_str(data))
File"/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/init.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
Error 2:
2019-09-21T13:14:11:ERROR:localstack.services.generic_proxy: Error forwarding request:'QueueUrl' Traceback (most recent call last):
File "/Users//workspaces/others/localstack/localstack/services/generic_proxy.py", line 240, in forward
path=path, data=data, headers=forward_headers)
File "/Users//workspaces/others/localstack/localstack/services/sqs/sqs_listener.py", line 53, in forward_request
self._set_queue_attributes(req_data)
File "/Users/*****/workspaces/others/localstack/localstack/services/sqs/sqs_listener.py", line 245, in _set_queue_attributes
queue_url = req_data['QueueUrl'][0]
KeyError: 'QueueUrl'`
Please help on this its a been a blocker for me.
This is because I was hitting http://localhost:4569 which isn't a user interface. So its throwing error.But if I create tables using aws cli and do some operations it just works fine without any issue.

selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value'

I am trying to automate my hybrid app, where I need to enter details in an input field but using send_keys("Text value") is not working in my case. I am getting the exception
selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value'
def test_login(self):
self.driver.implicitly_wait(15)
loginemail = self.driver.find_element_by_id("userId")
loginpass = self.driver.find_element_by_id("userPassword")
email = loginemail.find_element_by_xpath("//*[#id='userId']/input")
email.click()
email.send_keys("xxxxlabs.com")
Here is the full error message:
File "/home/martial/PycharmProjects/pytestAndroid/test_login_android.py", line 45, in test_login
email.send_keys("xxxxlabs.com")
File "/home/martial/PycharmProjects/pytestAndroid/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 347, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
File "/home/martial/PycharmProjects/pytestAndroid/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 491, in _execute
return self._parent.execute(command, params)
File "/home/martial/PycharmProjects/pytestAndroid/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "/home/martial/PycharmProjects/pytestAndroid/venv/lib/python3.6/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
File "/home/martial/PycharmProjects/pytestAndroid/venv/lib/python3.6/site-packages/appium/webdriver/errorhandler.py", line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File "/home/martial/PycharmProjects/pytestAndroid/venv/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value'
I was getting this error when using chromedriver v2.33 - when I updated to v2.36 the error went away (this was on the mac using the chromedriver_mac64.zip file downloaded from: https://sites.google.com/a/chromium.org/chromedriver/downloads)
Question: org.openqa.selenium.webdriverexception: unknown error: call function result missing 'value'. Please look into below steps to resolve such error.
Answer: Update browser version. Please follow below steps to get the latest version of browsers.
Go to: https://www.seleniumhq.org/download/
CTRL+F and search "Third Party Browser Drivers". All browsers are listed there.
Click on browser name/version -It redirects to the another page. (E.g.- http://chromedriver.storage.googleapis.com/index.html?path=2.36/)
Download appropriate driver for your operating system.
Place driver into one of folder from where you are calling that driver to your selenium webdriver scripts. It works without any error.
Thanks :) !!

memsql-ops start error in thread-7

After installing and starting memsql-ops, it shows the following error:
# ./memsql-ops start
Starting MemSQL Ops...
Exception in thread Thread-7:
Traceback (most recent call last):
File "/usr/local/updated-openssl/lib/python3.4/threading.py", line 921, in _bootstrap_inner
File "/usr/local/updated-openssl/lib/python3.4/threading.py", line 869, in run
File "/memsql_platform/memsql_platform/agent/daemon/manage.py", line 200, in startup_watcher
File "/memsql_platform/memsql_platform/network/api_client.py", line 34, in call
File "/usr/local/updated-openssl/lib/python3.4/site-packages/simplejson/__init__.py", line 516, in loads
File "/usr/local/updated-openssl/lib/python3.4/site-packages/simplejson/decoder.py", line 370, in decode
File "/usr/local/updated-openssl/lib/python3.4/site-packages/simplejson/decoder.py", line 400, in raw_decode
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Does anyone know the issue?
OS : CentOS 6.7
Memsql : 5.1.0 Enterprise Trial
It is likely that you have another server running on the port Ops is trying to start with (default 9000) that is returning data which is not JSON decodable. The solution is to either start MemSQL Ops on a different port, or kill the server running at that port.
We will fix this bug in an upcoming release of Ops! Thanks for pointing it out.

Catch exceptions in CherryPy 3.2 during body.process

I got the following error in a live site where a utf character (test string 'Îñţérñâţîöñåļîžæ†îøñ') was submitted:
400 Bad Request
The request entity could not be decoded. The following charsets were attempted: ['utf-8']
Traceback (most recent call last):
File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 648, in respond
self.body.process()
File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cpreqbody.py", line 931, in process
super(RequestBody, self).process()
File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cpreqbody.py", line 500, in process
proc(self)
File ".virtual/local/lib/python2.7/site-packages/cherrypy/_cpreqbody.py", line 153, in process_urlencoded
"charsets were attempted: %s" % repr(entity.attempt_charsets))
HTTPError: (400, "The request entity could not be decoded. The following charsets were attempted: ['utf-8']")
Powered by CherryPy 3.2.0
I can fix this using <form type="POST" accept-charset="utf-16">.
Normally, I catch errors in application code and log them or email them to myself, but this error never reached my application code which runs on TurboGears 1.5.
Any idea on how I can hook in to catch and log errors generated by CherryPy, and secondarily, give the user a better 404 page?
The method of error handling listed at _cperror.html#unanticipated-errors
doesn't work for this sort of error (but kicks in on e.g. static file missing)

Resources