$ window.open caused by a promise breaks the second promise

I am new to angularjs. Love it, but sometimes I get surprises that I just can't seem to find the answer.

I have a function that allows the user to create a list to a file by clicking a link. It can take up to a minute for the user to create different lists at the same time. The point is that after the file is created, a pop-up window appears to download it. It all works when only 1 file is created. After half a minute, a download popup appears. But when 2 are being built at the same time, the second POST is canceled (it comes in the error callback) when the popup appears.

If I remove $ window.open both POSTs succeed and I get both files in the console log.

Clearly the problem lies with $ window.open. But why? What am I doing wrong or how can I solve this? Any idea? I have been searching for hours now but cannot find anything in this case.

 $scope.idPromise = $http.post(restPath, $scope.data)
              .then(function(data){
console.log(data.data);
console.log(data.data.fileId);
$window.open(restPath + 'files/' + data.data.fileId, '_self');
},function(error){
console.log('promise error')
            });

      

So, when two lists are built without window.open in code, I get something like this in my console:

POST http: // localhost: 8080 / xxx-rest / rest / lijsten / vastelijsten / gezinshoofdenMetLeden 200 OK 1m

POST http: // localhost: 8080 / xxx-rest / rest / lijsten / vastelijsten / gezinshoofdenMetLeden 200 OK 1m 40s

report3545743463669473959.xlsx

report4733168386603499105.xlsx

when window.open is put into code:

POST http: // localhost: 8080 / xxx-rest / rest / lijsten / vastelijsten / gezinshoofdenMetLeden 200 OK 1m

POST http: // localhost: 8080 / xxx-rest / rest / lijsten / vastelijsten / gezinshoofdenMetLeden x 56,39s

report1588183186872251177.xlsx

Promise error

As you can see, the last POST stops as soon as the first POST receives a response, so no response is received for the second POST.

Update

The problem seems to be with the grunt server and the liveReload protocol. My college always told me to ignore this error, but it is now clear that as the page loses link that promises to fail.

Does anyone have any experience with grunt and liveReload? Can I fix this? Will it work on a production server?

Console error I am getting:

De verbinding met ws: // localhost: 35729 / livereload werd onderbroken tijdens het laden van de pagina. this.socket = new this.WebSocket (this._uri);

(translation: connection with ... was interrupted)

+3


source to share





All Articles