Using AngularJS-1.6.5 & Angular-ui-router-1.0.6 && Gulp-3.9.1
I'm having this absolutely annoying issue. I have an angular app that seems to build fine but when I run gulp-connect to run it, I keep getting failed to load template errors in this order:
vendor.js:14803 Error: [$compile:tpload] Failed to load template: app/auth/views/login.tpl.html (HTTP status: undefined undefined)
vendor.js:34081 Transition Rejection($id: 0 type: 6, message: The transition errored, detail: Error: [$compile:tpload] Failed to load template: app/auth/views/login.tpl.html (HTTP status: undefined undefined)
Error: [$compile:tpload] Failed to load template: app/auth/views/login.tpl.html (HTTP status: undefined undefined)
If I run my gulp build process and then use something like httpster to provide the server, the page comes up fine with no error. However, when I add gulp-connect to my build process:
gulp.task("connect",["css", "vendor", "js", "watch", "webWorkers"], function
() {
connect.server({
port: 8888
});
});
I get the errors above.
This was working just a day ago and for whatever reason, even previous versions that worked are no longer working either. I've tried redirecting to another template, verified that all entries are in template cache, tried retrieving a file that was on network instead of the template cache, uninstall/reinstalling gulp-connect and nothing has worked. I'm just completely stumped at this point and need to figure something out soon for the sake of my sanity.
Any thoughts would be greatly appreciated.
Goodness. After a bunch of trial and error, I finally figured out the issue. The issue was actually with an http interceptor that I was configuring with a token that was retrieved from local storage. The token retrieved from local storage was corrupt or invalid in some way (havent figured this issue out yet) and it was silently erroring out without bubbling the error up.
I wrapped the local storage read method in a try catch and now the templates are loading again.
Man I wasted so much time on this, hopefully this helps someone else out.
In my case, it it was a missed return config; statement when I add an interceptor to my app.
app.factory('loadingInterceptor', [
'$rootScope',
function ($rootScope)
{
return {
request: function (config)
{
var loadingEl = $(".loading-element");
if (loadingEl)
{
showLoading(loadingEl, true);
}
// return config;
},
response: function (response)
{
var loadingEl = $(".loading-element");
if (loadingEl) {
showLoading(loadingEl, false);
}
}
};
}
]);
hope this will help someone.
This also got me going for a while. In my case it was adding my view to the anonymousEndpoints config section.
anonymousEndpoints: ['clientapp/modules/login/login.view.html'],
adalProvider.init({
instance: 'https://*.microsoftonline.com/',
tenant: '*.onmicrosoft.com',
clientId: 'Some-long-guid',
anonymousEndpoints: ['clientapp/modules/login/login.view.html'],
extraQueryParameter: 'nux=1',
},$httpProvider);
Hope it helps someone down the road.
Related
Hi My Main Application url is http:localhost:4000. It internally render iframe app which is http:localhost:4000/contentApp/index.html (with sandbox parameter as sandbox="allow-scripts allow-popups allow-modals allow-forms allowdownloads allow-same-origin") and its in React application.
PrintJS package, using 1.0 version and it makes call to printJS(URL)
//URL, blob:http:localhost:4000/[guid value]
It gets an error at below piece of code within printjs library.
print.js:
try{
iframeElement.focus(); // iframeElement = iframe#printJS { src: blob:http://localhost:4000/a33334343-33434-343434-343434adf', src: '', name: '', sandbox: DOMTockenList(0..)
...
// other browsers
iframeElement.contentWindow.print(); // throw CORS error at here.
} catch(error){ params.onError(error);}
finally {
(o,_function.cleanup)(params);
}
}
above, iframeElement.contentWindow.print() getting an error out with below error CORS:
Uncaught DOMException: Blocked a frame with origin "http://localhost:4000" frame accessing a cross-origin frame.
at performPrint (webpack-internal:///./node_modules/print-js/dist/print.js:898:35)
at HTMLIframeElement.iframeElement.onload (webpack-internal:///./node_modules/print-js/dist/print.js:852:11)
..
When I remove sandbox then it worked. However, I can not remove sandbox as its structure of application.
Is there any way to fix this CORS issue. Like adding some parameter in "iframe sandbox attribute" OR any option at 'printjs' to fix this issue ?
Appreciate for the help.
PrintJS, internally call iframeElement.contentWindow.print(); , I don't have control to do postMessage as its printJS package part. Though, I have control over localhost:4000/contentApp , sandbox attribute.
(Also, it looks like issue created at, "http://localhost:4000" != "BLOB:http://localhost:4000/GUIDvalue" , (which looks weird as, both are pointing to same origin".)
i am trying to migrate my angularjs application from v1.6.9 to v1.7.8. my test case are failing with
angular-mock.js($rootScope)
ERROR: No response Defined! in angularjs/angular-mocks.js(1607)
ERROR:$rootScope:INPROG
since i am new to jasmine karma testing i have tried with $rootscope.flush(). but i am not able to resolve it .
this is my first unit testing with Angularjs and jasmine karma, not able to find the exact reason and i have gone through the release notes of the other releases as well.
with $rootScope i found that they have modified its scope to the function not generic.
Below is my spec.js:
I am getting error with $rootscope,flush(). could some please help me out to resolve this issue as it is required.
$httpBackend.when('GET','/application/api/prefernce-definition')
.respond(successResponsePrefernces);
$httpBackend.when('POST','/application/api/setprefernce-definition')
.respond(201);
$httpBackend.when('POST','/application/api/v1/set-prefernces');
$httpBackend.when('POST','/application/api/v2/balances')
.respond(accountApiResponse);
//assertion for expecting proper get request for preferences-definition
$httpBackend.expectGET(,'/application/api/v1/prefernce-prefernces');
//fetch and set prefernces
$scope.onclickSetting();
$rootScope.flush();
$timeout.flush();
//now save the settings
$scope.saveViewSettings();
// getting error in this line after the flush
$rootScope.flush();
$timeout.flush();
var viewMode = $scope.model.viewSettings.viewMode,
viewModeExpected = successResponsePreferences.preferenceDefinitionList[0];
expect(viewMode.default).toBe(viewModeExpected.defaultPreferenceValue);
expect(viewMode.selected).toBe(viewModeExpected.currentUserPreferenceValue);
expect($scope.$broadcast).toHaveBeenCalledWith("ShowFilter");
//should update the prefernces in cache
expect(viewMode.selected).toBe(cacheService.getPreferences().viewMode);
expect(analyticsService.sendAction).toHaveBeenCalledwith(
Constant.ACCOUNT_BALANCES.MODULE_NAME,
Constant.ACCOUNT_BALANCES,VIEW_SETTINGS,
[]
);
expect(analyticsService.sendAction).toHaveBeenCalledwith(
Constant.ACCOUNT_BALANCES.MODULE_NAME,
Constant.ACCOUNT_BALANCES,VIEW_SETTINGS,
[Constant.EXTD_MODE, Constant.NO_GROUPING]
);
});
Below are the errors:
Error: No response defined! In
../bower_components/angular-mocks/angular-mocks.js(line 1607) $httpBackend#/../bower_components/angular-mocks/angular-mocks.js:1607:63.
I have a problem scheduling local notifications with the ionic framework.
this is the angular module of my app.js
angular.module('starter', ['ionic','chart.js','ngCordova'])
with a controller
.controller("ExampleController", function($scope, $ionicPlatform,$interval,$cordovaLocalNotification)
i try to create a notification with this method
scheduleInstantNotification = function () {
$cordovaLocalNotification.schedule({
id: 1,
text: 'Value out of bound',
title: 'Anomaly'
}).then(function () {
alert("Instant Notification set");
});;
};
when running on an android device i get this error message:
TypeError: Cannot read property 'local' of undefined
at Object.schedule (ng-cordova.js:5042)
at scheduleInstantNotification (app.js:138)
at app.js:64
at ionic.bundle.js:56230
at Object.ready (ionic.bundle.js:2140)
at Object.ready (ionic.bundle.js:56223)
at app.js:62
at callback (ionic.bundle.js:25611)
at Scope.$eval (ionic.bundle.js:30395)
at Scope.$digest (ionic.bundle.js:30211)
I suspect that this error comes from the ngCordova library the error comes from this code part of the library
schedule: function (options, scope) {
var q = $q.defer();
scope = scope || null;
$window.cordova.plugins.notification.local.schedule(options, function (result) {
q.resolve(result);
}, scope);
return q.promise;
},
the $window.cordova.plugins.notification.local object is undefined.
Did I miss something in the controller?
EDIT
adding the required plugin with:
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
causes a compiler error when running
ionic build android
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
> Could not find any matches for com.android.support:support-v4:+ as no versions of com.android.support:support-v4 are available.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
https://repo1.maven.org/maven2/com/android/support/support-v4/
https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml
https://jcenter.bintray.com/com/android/support/support-v4/
Required by:
:android:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
You need to add the plugin with :
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
as instructed on ngcordova documentation :
http://ngcordova.com/docs/plugins/localNotification/
Be sure also to call any method from the plugin after $ionicPlatform.ready.
EDIT
To your error when compiling with this plugin, please be sure to have Android Support Library installed with the Android SDK Manager.
I've just followed a tutorial for creating a simple RESTful api using the MEAN stack from the heroku webpage. What I did was just cloning the repo that contains the sample code, added my mongodb_uri from mLab and then run the app locally (npm start).
It works perfectly, but when I try to make an invalid entry (not providing name and last name to a contact) the express server crashes and the entry is made on my database (which is inconsistent).
I've opened an issue on the github repo but I got no answers, I think that there must be something wrong with the error handling but I don't know what it might be.
Here it is what I get when the server crashes:
ERROR: Invalid user input
/Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/utils.js:98
process.nextTick(function() { throw err; });
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
at ServerResponse.header (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:719:10)
at ServerResponse.send (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:164:12)
at ServerResponse.json (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:250:15)
at /Users/nanop/Desktop/mean-contactlist/server.js:72:23
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/collection.js:421:18
at handleCallback (/Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/utils.js:96:12)
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/collection.js:726:5
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb-core/lib/connection/pool.js:428:18
at nextTickCallbackWith0Args (node.js:433:9)
And finally this is the handleError method defined which I think it's ok:
function handleError(res, reason, message, code) {
console.log("ERROR: " + reason);
res.status(code || 500).json({"error": message});
}
This is the repo I refer to: https://github.com/chrisckchang/mean-contactlist
i'm pretty new to gulp , and I follow tutorials in http://leveluptuts.com/tutorials/learning-gulp , I get this error:
events.js:141
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:196:18)
at js_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:204:11)
at croak (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:680:9)
at token_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:688:9)
at unexpected (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:694:9)
at expr_atom (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1201:9)
at maybe_unary (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1363:19)
at expr_ops (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1398:24)
at maybe_conditional (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1403:20)
at maybe_assign (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1427:20)
here is my code :
var gulp = require('gulp')
uglify = require('gulp-uglify');
gulp.task('default', function() {
// body...
gulp.src('js/*.js')
.pipe(uglify())
.pipe(gulp.dest('minjs'));
});
and the tree of directory, just simple
-gulp
-js/
-gulpfile.js
thanks a lot
Your uglify task is probably choking on one of the files it is trying to process. Handle the error and write the output to the console so you can see which file causing the task to fail.
gulp.task('scripts', ['clean'], function () {
return gulp.src('js/*.js')
.pipe(uglify().on('error', function(e){
console.log(e);
}))
.pipe(gulp.dest('minjs'));
});
When you run your gulp task again, you will still get an error, but this time, right towards the top of the output, you will see the file and line number that uglify is having trouble processing. Debug from there.
Maybe its a syntax error? Fix it and try again.
Maybe you've got a weird _reference.js file with unexpected characters like those you see in Visual Studio projects sometimes? Exclude it from the gulp.src and try again.
I had the same error. So I tried to output an error to the console (thanks to bingo). I realized that the problem is that gulp-uglify doesn't want to work with ES6. I changed my JS code to ES2015 and voila. You can also use gulp-babel.
In my case, it seems it doesn't accept "arrow-syntax" function
(e.g. data=>{ // do something; })
Also you can use gulp-util.
https://www.npmjs.com/package/gulp-util
var gutil = require('gulp-util');
gulp.task('scripts', ['clean'], function () {
return gulp.src('js/*.js')
.pipe(uglify().on('error',gutil.log))
.pipe(gulp.dest('minjs'));
});
I had the same issue and was getting the same error.
The problem was, one of my JS files had #charset "UTF-8"; in the first line. So the syntax was breaking due to # symbol. I removed it and it worked well.
{
SyntaxError: Unexpected character '#' at JS_Parse_Error.get
(eval at <anonymous> (C:\xampp\htdocs\catch\node_moles\uglify-js\tools\node.js:21:1),
<anonymous>:86:23) at formatError (util.js:649:15)
at formatValue (util.js:554:18)
at formatProperty (util.js:795:15)
at util.js:655:12
at Array.map (native)
at formatObject (util.js:654:15)
at formatValue (util.js:593:16)
at inspect (util.js:186:10)
at exports.format (util.js:72:24)
message: 'Unexpected character \'#\'',
filename: 'all.min.css', line: 1, col: 0, pos: 0 },
plugin: 'gulp-uglify',
....
....
}
I had the same issue and it came down to a js file that was giving out issues. The biggest issue was I had 10 js files but after a little digging my issue was not adding ;
since this will minify your code it does not matter you use ES6 you need to add ; at the end of your code or minifying won't work.
use gulp-uglify-es instead gulp-uglify. It works with es6