Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. #13

Open
niemyjski opened this issue May 15, 2015 · 17 comments
Labels

Comments

@niemyjski
Copy link
Collaborator

I get the following error in chrome when loadSource is called:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
function loadSource(url) {
        if (typeof url !== 'string') {
          return [];
        }

        if (!TraceKit.remoteFetching) { //Only attempt request if remoteFetching is on.
            return '';
        }
        try {
            var getXHR = function() {
                try {
                    return new window.XMLHttpRequest();
                } catch (e) {
                    // explicitly bubble up the exception if not found
                    return new window.ActiveXObject('Microsoft.XMLHTTP');
                }
            };

            var request = getXHR();
            request.open('GET', url, false);
            request.send('');
            return request.responseText;
        } catch (e) {
            return '';
        }
    }
@niemyjski niemyjski added the bug label May 15, 2015
@niemyjski
Copy link
Collaborator Author

I think this code may also have issues on IE 8/9... I'd like to abstract this code so we could inject node specific / web specific logic to get the source.

@niemyjski
Copy link
Collaborator Author

I've battle tested some code here: https://github.com/exceptionless/Exceptionless.JavaScript/blob/master/src/submission/DefaultSubmissionClient.ts#L56-L161 We should take a look and slim this down to fit this use case.

@yavorg
Copy link

yavorg commented Dec 27, 2015

Do you recommend we leave remoteFetching off in production until this is addressed?

@niemyjski
Copy link
Collaborator Author

Yeah, I think we should make this the default, as it could cause extra requests to be made

@niemyjski
Copy link
Collaborator Author

Can you submit a pull request for this.

@adi518
Copy link

adi518 commented Jul 31, 2016

Why do you fetch with a sync request anyway? :)

@niemyjski
Copy link
Collaborator Author

@adi518 I didn't write this logic but I assume it's because it has to work in ie6, we try and have it work as expected on all browsers.

@vivekmarakana
Copy link

Also, we need URL validation before making call. Sometimes error stack is not valid and that leads the call to eval at globalEval (http://cms.pharmeasy.in/assets/a929fb88/jquery.js:2:3123), <anonymous> for context

@niemyjski
Copy link
Collaborator Author

@vivekmarakana would you mind looking into this?

@vivekmarakana
Copy link

sure

@sdwvit
Copy link

sdwvit commented Jan 6, 2017

Hey, any updates on this? Maybe drop support of ie6 (and maybe 7,8,9)?

@niemyjski
Copy link
Collaborator Author

niemyjski commented Jan 6, 2017

I never heard back, would you mind looking into it? I don't see us dropping support for IE anytime soon. (https://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0) there are probably ~billion?? at least in the millions users still running those crappy versions of IE and we need to detect errors still for them :(.

@marceloogeda
Copy link

I recently received this as a warning level in Chrome version 63.0.3239.x

captura de tela 2017-12-19 as 11 28 27

@niemyjski
Copy link
Collaborator Author

@marceloogeda Would you mind submitting a pull request for a newer implementation that falls back based on support?

@marceloogeda
Copy link

@niemyjski sure, I'll make the required changes and submit it.

@niemyjski
Copy link
Collaborator Author

Might be able to take the code from here: https://github.com/exceptionless/Exceptionless.JavaScript/blob/master/src/submission/DefaultSubmissionAdapter.ts but we need to be sure we try catch any errors.

@niemyjski
Copy link
Collaborator Author

Can anyone submit a pr for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants