Flutter Web - XMLHttpRequest error when running google maps queries using google maps web service package - xmlhttprequest

Trying to work with -> google_maps_webservice: 0.0.20-nullsafety.5
When running await directions.GoogleMapsDirections(
apiKey: API_KEY).DirectionsWithLocation(l1, l2);
so that I can get a polyline between 2 coordinates I get:
Error: XMLHttpRequest error.
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 963:28 get current
packages/http/src/browser_client.dart 69:22 <fn>
dart-sdk/lib/async/zone.dart 1685:54 runUnary
dart-sdk/lib/async/future_impl.dart 147:18 handleValue
dart-sdk/lib/async/future_impl.dart 766:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 795:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 557:7 [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
dart-sdk/lib/async/stream.dart 1530:7 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39 dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37309:58 <fn>
at Object.createErrorWithStack (http://localhost:40789/dart_sdk.js:5093:12)
at Error._throw (http://localhost:40789/dart_sdk.js:20399:18)
at Error.throwWithStackTrace (http://localhost:40789/dart_sdk.js:20396:18)
at async._AsyncCallbackEntry.new.callback (http://localhost:40789/dart_sdk.js:40921:18)
at Object._microtaskLoop (http://localhost:40789/dart_sdk.js:40778:13)
at _startMicrotaskLoop (http://localhost:40789/dart_sdk.js:40784:13)
at http://localhost:40789/dart_sdk.js:36261:9
I know this is a CORS issue - but all I find on StackOverflow is some Js solution - which I don't really understand.
Is there a way to fix this using dart or some packages?

Related

Why does navigating to a route work, but when i put that URL into the address bar (Or reload page after navigating to it) express server returns error

I'm using an Express server, and everything seem to be working fine. I run my Angular application on it and it runs as it should Navigating between the different routes works like a charm.
But if I navigate to a route, and reload the page in browser, the server returns "Internal Server Error" and the following appears in my server log:
Error
at XMLHttpRequest3.send (/Users/<path-to>/server/main.js:1:4025798)
at Observable._subscribe (/Users/<path-to>/server/main.js:1:4264955)
at Observable._trySubscribe (/Users/<path-to>/server/main.js:1:3520438)
at Observable.subscribe (/Users/<path-to>/server/main.js:1:3520220)
at DoOperator.call (/Users/<path-to>/server/main.js:1:3583421)
at Observable.subscribe (/Users/<path-to>/server/main.js:1:3520074)
at CatchOperator.call (/Users/<path-to>/server/main.js:1:3562760)
at Observable.subscribe (/Users/<path-to>/server/main.js:1:3520074)
at scheduleTask (/Users/<path-to>/main.js:1:640743)
at Observable._subscribe (/Users/<path-to>/server/main.js:1:641346)
Unhandled Promise rejection: req.next is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: req.next is not a function
at done (/Users/<path-to>/server/main.js:1:2200666)
at _ZoneDelegate2.invoke (/Users/<path-to>/server/main.js:1:4048589)
at Zone3.run (/Users/<path-to>/server/main.js:1:4040924)
at /Users/<path-to>/server/main.js:1:4068136
at _ZoneDelegate2.invokeTask (/Users/<path-to>/server/main.js:1:4049527)
at Zone3.runTask (/Users/<path-to>/main.js:1:4042009)
at drainMicroTaskQueue (/Users/<path-to>/server/main.js:1:4053298) TypeError: req.next is not a function
at done (/Users/<path-to>/server/main.js:1:2200666)
at _ZoneDelegate2.invoke (/Users/<path-to>/server/main.js:1:4048589)
at Zone3.run (/Users/<path-to>/server/main.js:1:4040924)
at /Users/<path-to>/server/main.js:1:4068136
at _ZoneDelegate2.invokeTask (/Users/<path-to>/server/main.js:1:4049527)
at Zone3.runTask (/Users/<path-to>/server/main.js:1:4042009)
at drainMicroTaskQueue (/Users/<path-to>/server/main.js:1:4053298)
Edit: The server crashes with the error below when i do a second reload.
/Users/<path-to>/server/main.js:1
var __defProp=Object.defineProperty,__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});(()=>{var __webpack_modules__={12560:(module2,__webpack_exports__2,__webpack_require__2)=>{"use strict";__webpack_require__2.r(__webpack_exports__2),__webpack_require__2.d(__webpack_exports__2,{AppServerModule:()=>AppServerModule,app:()=>app,renderModule:()=>renderModule,renderModuleFactory:()=>renderModuleFactory});var transports_namespaceObject={};__webpack_require__2.r(transports_namespaceObject),__webpack_require__2.d(transports_namespaceObject,{BaseTransport:()=>BaseTransport,HTTPSTransport:()=>HTTPSTransport,HTTPTransport:()=>HTTPTransport,makeNodeTransport:()=>makeNodeTransport});var integrations_namespaceObject={};__webpack_require__2.r(integrations_namespaceObject),__webpack_require__2.d(integrations_namespaceObject,{Console:()=>Console,ContextLines:()=>ContextLines,Http:()=>Http,LinkedErrors:()=>LinkedErrors,Modules:()=>Modules,OnUncaughtException:()=>OnUncaughtException,OnUnhandledRejection:()=>OnUnhandledRejection});var esm_integrations_namespaceObject={};__webpack_require__2.r(esm_integrations_namespaceObject),__webpack_require__2.d(esm_integrations_namespaceObject,{FunctionToString:()=>FunctionToString,InboundFilters:()=>InboundFilters});var handlers_namespaceObject={};__webpack_require__2.r(handlers_namespaceObject),__webpack_require__2.d(handlers_namespaceObject,{errorHandler:()=>errorHandler,extractRequestData:()=>extractRequestData,parseRequest:()=>parseRequest,requestHandler:()=>requestHandler,tracingHandler:()=>tracingHandler});var node_esm_namespaceObject={};__webpack_require__2.r(node_esm_namespaceObject),__webpack_require__2.d(node_esm_namespaceObject,{Handlers:()=>handlers_namespaceObject,Hub:()=>Hub,Integrations:()=>INTEGRATIONS,NodeBackend:()=>NodeBackend,NodeClient:()=>NodeClient,SDK_NAME:()=>SDK_NAME,SDK_VERSION:()=>SDK_VERSION,Scope:()=>scope_Scope,Session:()=>Session,Severity:()=>Severity,Transports:()=>transports_namespaceObject,addBreadcrumb:()=>addBreadcrumb,addGlobalEventProcessor:()=>addGlobalEventProcessor,captureEvent:()=>captureEvent,captureException:()=>captureException,captureMessage:()=>captureMessage,close:()=>sdk_close,configureScope:()=>configureScope,deepReadDirSync:()=>deepReadDirSync,defaultIntegrations:()=>defaultIntegrations,flush:()=>flush,getCurrentHub:()=>getCurrentHub,getHubFromCarrier:()=>getHubFromCarrier,getSentryRelease:()=>getSentryRelease,init:()=>init,lastEventId:()=>lastEventId,makeMain:()=>makeMain,setContext:()=>setContext,setExtra:()=>setExtra,setExtras:()=>setExtras,setTag:()=>setTag,setTags:()=>setTags,setUser:()=>setUser,startTransaction:()=>startTransaction,withScope:()=>withScope});var integrations_namespaceObject_0={};__webpack_require__2.r(integrations_namespaceObject_0),__webpack_require__2.d(integrations_namespaceObject_0,{FunctionToString:()=>functiontostring_FunctionToString,InboundFilters:()=>inboundfilters_InboundFilters});var browser_esm_integrations_namespaceObject={};__webpack_require__2.r(browser_esm_integrations_namespaceObject),__webpack_require__2.d(browser_esm_integrations_namespaceObject,{Breadcrumbs:()=>Breadcrumbs,Dedupe:()=>Dedupe,GlobalHandlers:()=>GlobalHandlers,LinkedErrors:()=>linkederrors_LinkedErrors,TryCatch:()=>TryCatch,UserAgent:()=>UserAgent});var esm_transports_namespaceObject={};__webpack_require__2.r(esm_transports_namespaceObject),__webpack_require__2.d(esm_transports_namespaceObject,{BaseTransport:()=>base_BaseTransport,FetchTransport:()=>FetchTransport,XHRTransport:()=>XHRTransport,makeNewFetchTransport:()=>makeNewFetchTransport,makeNewXHRTransport:()=>makeNewXHRTransport});var browser_esm_namespaceObject={};__webpack_require__2.r(browser_esm_namespaceObject),__webpack_require__2.d(browser_esm_namespaceObject,{BrowserClient:()=>BrowserClient,Hub:()=>hub_Hub,Integrations:()=>esm_INTEGRATIONS,SDK_NAME:()=>version_SDK_NAME,SDK_VERSION:()=>version_SDK_VERSION,Scope:()=>scope_Scope_0,Session:()=>session_Session,Severity:()=>severity_Severity,Transports:()=>esm_transports_namespaceObject,addBreadcrumb:()=>minimal_addBreadcrumb,addGlobalEventProcessor:()=>scope_addGlobalEventProcessor,captureEvent:()=>minimal_captureEvent,captureException:()=>minimal_captureException,captureMessage:()=>minimal_captureMessage,close:()=>esm_sdk_close,configureScope:()=>minimal_configureScope,defaultIntegrations:()=>sdk_defaultIntegrations,eventFromException:()=>eventFromException,eventFromMessage:()=>eventbuilder_eventFromMessage,flush:()=>sdk_flush,forceLoad:()=>forceLoad,getCurrentHub:()=>hub_getCurrentHub,getHubFromCarrier:()=>hub_getHubFromCarrier,init:()=>sdk_init,injectReportDialog:()=>injectReportDialog,lastEventId:()=>sdk_lastEventId,makeMain:()=>hub_makeMain,onLoad:()=>onLoad,setContext:()=>minimal_setContext,setExtra:()=>minimal_setExtra,setExtras:()=>minimal_setExtras,setTag:()=>minimal_setTag,setTags:()=>minimal_setTags,setUser:()=>minimal_setUser,showReportDialog:()=>showReportDialog,startTransaction:()=>minimal_startTransaction,withScope:()=>minimal_withScope,wrap:()=>sdk_wrap});__webpack_require__2(97584);var TagContentType,TagContentType2,tslib_es6=__webpack_require__2(70655);function splitNsName(elementName){if(":"!=elementName[0])return[null,elementName];const colonIndex=elementName.indexOf(":",1);if(-1===colonIndex)throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);return[elementName.slice(1,colonIndex),elementName.slice(colonIndex+1)]}function isNgContainer(tagName){return"ng-container"===splitNsName(tagName)[1]}function isNgContent(tagName){return"ng-content"===splitNsName(tagName)[1]}function isNgTemplate(tagName){return"ng-template"===splitNsName(tagName)[1]}function getNsPrefix(fullName){return null===fullName?null:splitNsName(fullName)[0]}function mergeNsAndName(prefix,localName){return prefix?`:${prefix}:${localName}`:localName}(TagContentType2=TagContentType||(TagContentType={}))[TagContentType2.RAW_TEXT=0]="RAW_TEXT",TagContentType2[TagContentType2.ESCAPABLE_RAW_TEXT=1]="ESCAPABLE_RAW_TEXT",TagContentType2[TagContentType2.PARSABLE_DATA=2]="PARSABLE_DATA",__name(splitNsName,"splitNsName"),__name(isNgContainer,"isNgContainer"),__name(isNgContent,"isNgContent"),__name(isNgTemplate,"isNgTemplate"),__name(getNsPrefix,"getNsPrefix"),__name(mergeNsAndName,"mergeNsAndName");class HtmlTagDefinition{constructor({closedByChildren,implicitNamespacePrefix,contentType=TagContentType.PARSABLE_DATA,closedByParent=!1,isVoid=!1,ignoreFirstLf=!1,preventNamespaceInheritance=!1}={}){this.closedByChildren={},this.closedByParent=!1,this.canSelfClose=!1,closedByChildren&&closedByChildren.length>0&&closedByChildren.forEach(tagName=>this.closedByChildren[tagName]=!0),this.isVoid=isVoid,this.closedByParent=closedByParent||isVoid,this.implicitNamespacePrefix=implicitNamespacePrefix||null,this.contentType=contentType,this.ignoreFirstLf=ignoreFirstLf,this.preventNamespaceInheritance=preventNamespaceInheritance}isClosedByChild(name){return this.isVoid||name.toLowerCase()in this.closedByChildren}getContentType(prefix){if("object"==typeof this.contentType){const overrideType=void 0===prefix?void 0:this.contentType[prefix];return null!=overrideType?overrideType:this.contentType.default}return this.contentType}}let _DEFAULT_TAG_DEFINITION,TAG_DEFINITIONS;function getHtmlTagDefinition(tagName){var _a,_b;return TAG_DEFINITIONS||(_DEFAULT_TAG_DEFINITION=new HtmlTagDefinition,TAG_DEFINITIONS={base:new HtmlTagDefinition({isVoid:!0}),meta:new HtmlTagDefinition({isVoid:!0}),area:new HtmlTagDefinition({isVoid:!0}),embed:new HtmlTagDefinition({isVoid:!0}),link:new HtmlTagDefinition({isVoid:!0}),img:new HtmlTagDefinition({isVoid:!0}),input:new HtmlTagDefinition({isVoid:!0}),param:new HtmlTagDefinition({isVoid:!0}),hr:new HtmlTagDefinition({isVoid:!0}),br:new HtmlTagDefinition({isVoid:!0}),source:new HtmlTagDefinition({isVoid:!0}),track:new HtmlTagDefinition({isVoid:!0}),wbr:new HtmlTagDefinition({isVoid:!0}),p:new HtmlTagDefinition({closedByChildren:["address","article","aside","blockquote","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5"
A server error has occurred.
node exited with 1 code.
I suspect this is a symptom of client side routing, which is typical of Single Page Applications (SPAs). As you navigate through your working application, you see your address bar entries change. But those are not URLs being requested from your Express server. Rather, your Angular framework is intercepting the request and invoking the JavaScript you packaged with your application.
The only "legitimate" URL for your application would be the one that initially loads your application. Everything you see in the address bar afterwards is recognized by your Angular router, but not by your Express server.

Scrapy - get depth level of failed requests with no response

When parsing scraped pages I also save the depth the request was scraped from using response.meta['depth'].
I recently started using errback to log all failed requests into a separate file and having depth there would help me a lot. (I believe) I could use failure.value.response.meta['depth'] for those pages which actually got a response but failed due to ie a http status error like 403 etc., however when an error like TCPTimeout is encountered there is no response.
Is it possible to get the depth level of a failed request with no response?
EDIT1: Tried failure.request.meta['depth'] but that gives an error. Meta seems that can be found but it has no depth key.
EDIT2: The issue seems to be that failure.request.meta['depth'] is created only when the first response is received. So the way I understand is that if the first request, a start_url doesn't receive a response, the depth key is not yet created and hence throws an exception.
I'm going to experiment with this as per the depth middleware:
if 'depth' not in response.meta:
response.meta['depth'] = 0
Yep, the issue turns out to be exactly how I described it in EDIT2. This is how I fixed it:
def start_requests(self):
for u in self.start_urls:
yield scrapy.Request(u, errback=self.my_errback)
def my_errback(self, failure):
if 'depth' not in failure.request.meta:
failure.request.meta['depth'] = 0
depth = failure.request.meta['depth']
# do something with depth...
Big thanks to mr #Galecio who pointed me in the right direction!

Angular7 + XHook gives ERROR TypeError: Illegal invocation

I have a chrome plugin runnin Xhook which intercepts xhr requests.
This used to work with angular js. Now I am using an Angular 7 application And I am getting an error when I make following request
this.http.get('someurl').subscribe((data: any) => {
});
Which triggers xhr.send(reqBody); in the angular http.js library. The error is on the subscribe part, if I remove this the error is gone.
The error is the following:
core.js:15724 ERROR TypeError: Illegal invocation
at ZoneTask.scheduleTask [as scheduleFn] (zone.js:3238)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask (zone.js:410)
at Object.onScheduleTask (zone.js:301)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask (zone.js:404)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask (zone.js:238)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.scheduleMacroTask (zone.js:261)
at scheduleMacroTaskWithCurrentZone (zone.js:1245)
at zone.js:3276
at _global.<computed>.proto.<computed> [as send] (zone.js:1569)
at Observable._subscribe (http.js:1726)
I am using this library: https://github.com/jpillora/xhook and the error is caused by line 478 facade.send = function(body) https://github.com/jpillora/xhook/blob/gh-pages/dist/xhook.js
I am thinking that: either angular tries to run the overridden function but something is not accessible because of zone.js, or I am missing certain properties, function in the object that overrides xhr?
If anyone has any information or solution on the subject that would be dearly appreciated.

Getting file upload error in dojo iframe - doc.getElementsByTagName('textarea')[0].value undefined error

Getting file upload error in dojo iframe - doc.getElementsByTagName('textarea')[0].value undefined error. File upload is failing intermittently when dojo(1.11.2 version) handleResponse() method is called before the response comes from the remote server .
Below is the error message i am getting
Error: HTML Upload Error:Cannot read property 'value' of undefined at
Object._error
(/public/prod/dojo-1.11.2/dojox/form/FileUploader.js:18:56) at
Object.d (:244:264) at Object._error
(/public/prod/revolution-3.8.5/revit/form/FileUploader.js:12:300) at
Object.eval
(/public/prod/dojo-1.11.2/dojox/form/FileUploader.js:23:457) at
Object.error (:44:382) at :149:461 at g
(:163:21) at h (:162:331) at
h.Deferred.reject.errback (:164:304) at g
(:163:293) Message
I spent lot of hours in resolving this issue.But some how it is not getting resolved.Can anyone help me .

WSO2 API Manager returning RunTime Error

I have an API in WSO2. When I try to test it in the store with valid parameters via GET, it returns the following error message:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>101504</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Send timeout</am:description>
</am:fault>
I have already searched and tried a lot, but with no success, always returning the same error. Don't know if helps, but the api that I try to access is a PHP file.
Any ideas?
EDIT:
I have identical apis to this one, changing only the response, that are working properly. Even if I erase the php file that the API is pointing, the error keep coming.
EDIT:
I changed the code in Management Console, in Metadata>List>APIs:
{"production_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"sandbox_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"implementation_status":"managed","endpoint_type":"http"}
to this:
{"production_endpoints":
{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"sandbox_endpoints":{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"implementation_status":"managed","endpoint_type":"http"}
And this error message vanishes. But this new one appears:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>303001</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Currently , Address endpoint : [ Name : admin--myapi_APIproductionEndpoint_0 ] [ State : SUSPENDED ]</am:description>
EDIT: this error message is appearing just sometimes. Most of the time the request takes long time to run and then returns nothing( no content )
Any ideas how to solve it?