Amplify-js: Refresh browser cause GraphQL error ns.GetCommandSrc is not a function

Created on 6 Sep 2019  路  8Comments  路  Source: aws-amplify/amplify-js

Describe the bug
Appsync + Amplify-js: Browser refresh (F5) cause server-side GraphQLError: ns.GetCommandSrc is not a function

To Reproduce

  1. Use the repo provided below
  2. npm i
  3. Reproduce the stack by amplify init and amplify push as following
$ amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project amplifygetcmdsrcbug
? Enter a name for the environment test
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path:  src
? Distribution Directory Path: build
? Build Command:  npm.cmd run-script build
? Start Command: npm.cmd run-script start

$ amplify add api
? Please select from one of the below mentioned services GraphQL
? Provide API name: amplifygetcmdsrcbug
? Choose an authorization type for the API API key
? Do you have an annotated GraphQL schema? No
? Do you want a guided schema creation? No
? Provide a custom type name MyType

$ amplify push
  1. npm start
  2. Look at developer console output, data.listMyTypes.items equals []
  3. Press F5 (or alternatives below)
  4. ERROR: GraphQLError: ns.GetCommandSrc is not a function

Expected behavior
data.listMyTypes.items should equals [], but the return looks like an internal error with unspecific GraphQL query location.

Screenshots
image

Desktop (please complete the following information):
Tested these versions

  • Chrome Version 76.0.3809.132
    F5 always bugs, hot-reload sometimes bugs. Ctrl+Shift+R never bugs.
  • Chrome Version 76.0.3809.100
    F5 nevery bugs. Ctrl+Shift+R never bugs.
  • Firefox 69.0:
    Try to cause react to hot-reload, e.g. by modifying <App /> as <div /> back and forth, sometimes it bugs out, not certain how it is actually caused. F5 ~1/10 chance bugs. Ctrl+Shift+R never bugs.

Sample code
https://github.com/kftsehk/amplify-getcmdsrc-bug/

First entry: normal

ConsoleLogger.js:101 [DEBUG] 30:39.712 RestClient - POST https://<api-id>.appsync-api.<region>.amazonaws.com/graphql
index.js:35 {data: {鈥}

Refresh

ConsoleLogger.js:103 [DEBUG] 31:05.850 RestClient TypeError: ns.GetCommandSrc is not a function
    at GetCommandUrl (main.js:988)
    at XMLHttpRequest.window.XMLHttpRequest.open (main.js:1023)
    at dispatchXhrRequest (xhr.js:32)
    at new Promise (<anonymous>)
    at xhrAdapter (xhr.js:16)
    at dispatchRequest (dispatchRequest.js:49)
index.js:1375 {data: {鈥, errors: Array(1)}
GraphQL pending-close-response-required

Most helpful comment

Thanks @laurentgoudet, I think you pin-point the cause. This computer has Kaspersky Internet Security 20.0.14.1085(d), disable an option called "Inject script into web traffic to interact with web pages", error gone.
Description says the script is used for Secure Data Input, Safe Money, Private Browsing, URL Advisor, Anti-Banner, Parental Control, most looks like non-core features.

There might be a (recent) version of script that is buggy, I tested on another Kaspersky (Internet Security 19.0.0.1088(g) installed PC, there is no such problem.

All 8 comments

I suspect your issue has nothing do to with Appsync nor Amplify-js. We're running an Angular app without GraphQL & I've stubbled into that issue after Googling GetCommandSrc as we've been seeing Uncaught (in promise): ns.GetCommandSrc is not a function a lot in our Sentry logs lately.

There's a pastebin with Kaspersky injected JS that contains ns.GetCommandSrc: are you running any sort of Kaspersky Internet protection product by any chance? It looks to me that one of their product is wrapping XMLHttpRequest::open() calls to analyze what web pages are doing, but their implementation is buggy, hence the error.

Thanks @laurentgoudet, I think you pin-point the cause. This computer has Kaspersky Internet Security 20.0.14.1085(d), disable an option called "Inject script into web traffic to interact with web pages", error gone.
Description says the script is used for Secure Data Input, Safe Money, Private Browsing, URL Advisor, Anti-Banner, Parental Control, most looks like non-core features.

There might be a (recent) version of script that is buggy, I tested on another Kaspersky (Internet Security 19.0.0.1088(g) installed PC, there is no such problem.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

I faced the same problem with post data to API and i have solved it by closing my anti virus

I suspect your issue has nothing do to with Appsync nor Amplify-js. We're running an Angular app without GraphQL & I've stubbled into that issue after Googling GetCommandSrc as we've been seeing Uncaught (in promise): ns.GetCommandSrc is not a function a lot in our Sentry logs lately.

There's a pastebin with Kaspersky injected JS that contains ns.GetCommandSrc: are you running any sort of Kaspersky Internet protection product by any chance? It looks to me that one of their product is wrapping XMLHttpRequest::open() calls to analyze what web pages are doing, but their implementation is buggy, hence the error.

How to fix this issus

Thanks @laurentgoudet, I think you pin-point the cause. This computer has Kaspersky Internet Security 20.0.14.1085(d), disable an option called "Inject script into web traffic to interact with web pages", error gone.
Description says the script is used for Secure Data Input, Safe Money, Private Browsing, URL Advisor, Anti-Banner, Parental Control, most looks like non-core features.

There might be a (recent) version of script that is buggy, I tested on another Kaspersky (Internet Security 19.0.0.1088(g) installed PC, there is no such problem.

This solution worked! Pausing Kapersky did not solve the problem but unchecking the "Inject script into web traffic to interact with web pages" removes these "ns.GetCommandSrc is not a function" errors.

Hi!
According to my information the issue should be fixed in the current patch H for 2020 version.
As the patch H is completely released, so it is necessary to make sure that it is installed, then retest the issue.

Was this page helpful?
0 / 5 - 0 ratings