question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail silently when API JSON response parsing failed

See original GitHub issue

I use react-table in a secure build environment. API requests from the build gets blocked. So when scarfJS tried to send same, it got blocked. I tried adding disable package.json config but didn’t work. Following is the error observed

16:26:52 
16:26:52 SyntaxError: Unexpected end of JSON input
16:26:52     at JSON.parse (<anonymous>)
16:26:52     at /local/apps/test/frontend/node_modules/@scarf/scarf/report.js:65:27
16:26:52 npm ERR! code ELIFECYCLE
16:26:52 npm ERR! errno 1
16:26:52 npm ERR! @scarf/scarf@0.1.5 postinstall: `node ./report.js`
16:26:52 npm ERR! Exit status 1
16:26:52 npm ERR! 
16:26:52 npm ERR! Failed at the @scarf/scarf@0.1.5 postinstall script.
16:26:52 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
16:26:52 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aviaviavicommented, Apr 16, 2020

Sure thing! API calls will not be fired if scarf is disabled

0reactions
jainrounak6commented, Nov 19, 2021
{
  "name": "client",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "compile:server": "webpack --config webpack.server.config.js --progress --colors",
    "serve:ssr": "node dist/server",
    "build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
    "build:client-and-server-bundles": "ng build --prod && ng run client:server:production --bundleDependencies all"
  },
  "private": true,
  "dependencies": {
    "1.0.2": "^1.0.0",
    "@angular/animations": "~8.2.0",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "^8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/platform-server": "~8.2.0",
    "@angular/pwa": "^0.1001.3",
    "@angular/router": "~8.2.0",
    "@angular/service-worker": "~8.2.0",
    "@kolkov/angular-editor": "1.0.2",
    "@ng-bootstrap/ng-bootstrap": "^5.1.2",
    "@ng-select/ng-select": "^3.7.0",
    "@nguniversal/express-engine": "^8.2.6",
    "@nguniversal/module-map-ngfactory-loader": "v8.2.6",
    "@ngx-meta/core": "^8.0.2",
    "@ngx-share/core": "^7.1.4",
    "@scarf/scarf": "^0.1.5",
    "angular-ng-autocomplete": "^1.1.14",
    "angular2-multiselect-dropdown": "^4.6.4",
    "bootstrap": "4.1.1",
    "chart.js": "2.9.3",
    "express": "^4.15.2",
    "font-awesome": "4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.4.1",
    "localstorage-polyfill": "^1.0.1",
    "moment": "^2.24.0",
    "mydatepicker": "^2.6.6",
    "ng2-charts": "2.3.0",
    "ng2-completer": "3.0.3",
    "ng2-search-filter": "0.5.1",
    "ng2-smart-table": "1.5.0",
    "ng2-tooltip-directive": "2.8.17",
    "ngx-bootstrap": "^5.1.0",
    "ngx-chips": "2.0.2",
    "ngx-image-cropper": "^2.0.2",
    "ngx-infinite-scroll": "8.0.1",
    "ngx-owl-carousel": "^2.0.7",
    "ngx-spinner": "8.1.0",
    "ngx-toastr": "^10.2.0",
    "rxjs": "^6.4.0",
    "rxjs-compat": "^6.5.3",
    "rxjs-observable": "0.0.7",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.802.0",
    "@angular/cli": "~8.2.0",
    "@angular/compiler-cli": "~8.2.0",
    "@angular/language-service": "~8.2.0",
    "@types/express": "^4.17.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "angular-ide": "^0.9.74",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-loader": "^5.2.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3",
    "webpack-cli": "^3.1.0"
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper way to catch exception from JSON.parse - Stack Overflow
i post something into an iframe then read back the contents of the iframe with json parse...so sometimes it's not a json string....
Read more >
Error while parsing JSON Response in REST API Post call
I switched to returning a JSON String and then Deserialize the JSON String, it still raises an error "Failed to parse response of...
Read more >
SyntaxError: JSON.parse: bad parsing Breaking Your Code ...
The JSON Parse error, as the name implies, surfaces when using the JSON. parse() method that fails to pass valid JSON as an...
Read more >
How to avoid building apps that crash by parsing JSON the ...
First of all, if the response is a JSON array instead of a dictionary, your app will crash at runtime. And second –...
Read more >
jQuery.getJSON() | jQuery API Documentation
Important: As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found