Tuesday 6 November 2018

Angular 4+ : Sudden @types/jasmine error at runtime (npm start)

We've been building our angular application on a day to day basis, as everyone should. :-P Then, suddenly the following error surfaced on our Development Pipeline on Jenkins:

chunk {styles} styles.js, styles.js.map (styles) 201 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 332 kB [initial] [rendered]

ERROR in node_modules/@types/jasmine/index.d.ts(138,47): error TS1005: ';' expected.
node_modules/@types/jasmine/index.d.ts(138,90): error TS1005: '(' expected.
node_modules/@types/jasmine/index.d.ts(138,104): error TS1005: ']' expected.

node_modules/@types/jasmine/index.d.ts(138,112): error TS1005: ',' expected.

We did not change any versions or anything (didn't touch package.json), except for typescript logic as part of development progress.

At the end of the day, this error occurred due to @types/jasmine publishing a new version. ALSO, we had the following configured in our package.json under the "devDependencies" section:


"@types/jasmine": "^2.8.6",
"@types/jasminewd2": "^2.0.3"

Removal of the caret '^' character resolved the issue.

So, in other words, because we had the caret character against the versions of:

  • @types/jasmine
  • @types/jasminewd2
...it made it vulnerable to subsequent publication of versions from @types/jasmine.

Hence, I've noted it here... :-)

-----
PS: For the record, short explanation of menaing of '~' and '^' character in package.json file:

  • '^' - It will update you to the most recent MAJOR version 
  • '~' - It will update you to the most recent MINOR version 
------
Enjoy!


502 Bad Gateway nginx error on Kubernetes docker instance

We have taken a JSON Web Token approach to handle authorization in our Spring Boot application. Everything was working fine up to a point when we started getting 502 Bad Gateway errors for no reason (or, that's what we thought).

We discovered that this happened due to the token size which increased as we progressed with the development of functionality, which in turn resulted in the generation of a larger token based on additional authorization information.

The question still remains, why are we getting a 502 Bad Gateway. The HTTP 502 occurred due to the size of the header and on response to the HTTP request coming in, the kubernetes proxy rejected the request due to its header size.

So, we had to add the following line to the ingress of our application's docker descriptor:

  • ingress.kubernetes.io/proxy-buffer-size: 16k
That solved it. Hope it is of help to someone. :-)