René's URL Explorer Experiment


Title: UnhandledPromiseRejection thrown from within SDK · Issue #41 · contentstack/contentstack-javascript · GitHub

Open Graph Title: UnhandledPromiseRejection thrown from within SDK · Issue #41 · contentstack/contentstack-javascript

X Title: UnhandledPromiseRejection thrown from within SDK · Issue #41 · contentstack/contentstack-javascript

Description: Greetings, It appears that the SDK has the potential to cause an UnhandledPromiseRejection when the Contentstack REST API returns a non-well-formed JSON response (such as HTML). In the future versions of Node.js, this will cause the proc...

Open Graph Description: Greetings, It appears that the SDK has the potential to cause an UnhandledPromiseRejection when the Contentstack REST API returns a non-well-formed JSON response (such as HTML). In the future versi...

X Description: Greetings, It appears that the SDK has the potential to cause an UnhandledPromiseRejection when the Contentstack REST API returns a non-well-formed JSON response (such as HTML). In the future versi...

Opengraph URL: https://github.com/contentstack/contentstack-javascript/issues/41

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"UnhandledPromiseRejection thrown from within SDK","articleBody":"Greetings,\r\n\r\nIt appears that the SDK has the potential to cause an `UnhandledPromiseRejection` when the Contentstack REST API returns a non-well-formed JSON response (such as HTML).\r\n\r\nIn the future versions of Node.js, this will cause the process to crash, as suggested by the deprecation warning:\r\n\r\n\u003e [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\r\n\r\n## Exception Example\r\n\r\n```\r\n$ node index.js\r\n(node:26048) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://REDACTED:443/v3/content_types/REDACTED/entries/?locale=en-us\u0026include_count=true\u0026environment=REDACTED reason: Unexpected token \u003c in JSON at position 9\r\n    at eval (webpack://Contentstack/./node_modules/node-fetch/lib/index.mjs?:276:32)\r\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\r\n(node:26048) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)\r\n(node:26048) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\r\n```\r\n\r\n## Minimal reproduction example\r\n\r\n```\r\nnpm install dotenv node-request-interceptor contentstack\r\n```\r\n\r\n```js\r\nrequire('dotenv').config()\r\n\r\nconst Contentstack = require('contentstack');\r\nconst { RequestInterceptor } = require('node-request-interceptor');\r\nconst { default: withDefaultInterceptors } = require('node-request-interceptor/lib/presets/default');\r\n\r\nconst interceptor = new RequestInterceptor(withDefaultInterceptors)\r\n\r\n// Log any outgoing requests to contentstack and return a mock HTML response\r\n// which will cause the SDK to throw an unhandled exception\r\ninterceptor.use((req) =\u003e {\r\n\r\n    console.log('%s %s', req.method, req.url.href);\r\n\r\n    return {\r\n        status: 401,\r\n        headers: {\r\n            'x-powered-by': 'node-request-interceptor',\r\n            'content-type': 'text/html'\r\n        },\r\n        body: `\r\n        \u003chtml\u003e\r\n        \u003chead\u003e\u003c/head\u003e\r\n        \u003cbody\u003e\r\n            \u003ch1\u003eUnauthorized\u003c/h1\u003e\r\n        \u003c/body\u003e\r\n        \u003c/html\u003e\r\n        `,\r\n    }\r\n});\r\n\r\nconst Stack = Contentstack.Stack(\r\n    process.env.CONTENTSTACK_API_KEY,\r\n    process.env.CONTENTSTACK_DELIVERY_TOKEN,\r\n    process.env.CONTENTSTACK_ENVIRONMENT,\r\n    process.env.CONTENTSTACK_DB_REGION || null,\r\n    { timeout: 5000 });\r\n\r\nStack.setHost(process.env.CONTENTSTACK_HOST);\r\n\r\nconst Query = Stack\r\n    .ContentType(process.env.CONTENTSTACK_CONTENT_TYPE)\r\n    .Query({})\r\n    .language(\"en-us\")\r\n    .includeCount();\r\n\r\n// Executing this async invocation cause an unhandled promise rejection\r\nQuery\r\n    .toJSON()\r\n    .find()\r\n    .then((res) =\u003e {\r\n        const [,count] = res;\r\n        console.log(`${count} total blogs.`);\r\n    }, function (err) {\r\n        // Error is not caught\r\n        console.error(err);\r\n    })\r\n    .catch((err) =\u003e {\r\n        // Error is not caught\r\n        console.error(err);\r\n    });\r\n\r\n```","author":{"url":"https://github.com/viglucci","@type":"Person","name":"viglucci"},"datePublished":"2021-01-20T00:37:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/41/contentstack-javascript/issues/41"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b152a3b1-3c70-5d31-2f5a-5a554b8fb529
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8F6E:3D5ADE:107D34F:15B6D5D:69814350
html-safe-nonce7538fb49b808f6347e4ba530122c8ad25bbbacb511211928923605530ef90a4b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjZFOjNENUFERToxMDdEMzRGOjE1QjZENUQ6Njk4MTQzNTAiLCJ2aXNpdG9yX2lkIjoiNzAwMjUzNTE5MzkzMjI4NDc1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1605213179d52f05af14023c550fee91373f5146615afb782c85dad3db4d1613
hovercard-subject-tagissue:789510428
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/contentstack/contentstack-javascript/41/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e6c0d072fbe2ce29cf37250eca0c421beef6806447b5968ae8233838e981865d/contentstack/contentstack-javascript/issues/41
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e6c0d072fbe2ce29cf37250eca0c421beef6806447b5968ae8233838e981865d/contentstack/contentstack-javascript/issues/41
og:image:altGreetings, It appears that the SDK has the potential to cause an UnhandledPromiseRejection when the Contentstack REST API returns a non-well-formed JSON response (such as HTML). In the future versi...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameviglucci
hostnamegithub.com
expected-hostnamegithub.com
None39fe8101494cbb823c09b619b68c80cd4d05ab7279997038dbe06bb91608abe1
turbo-cache-controlno-preview
go-importgithub.com/contentstack/contentstack-javascript git https://github.com/contentstack/contentstack-javascript.git
octolytics-dimension-user_id24450751
octolytics-dimension-user_logincontentstack
octolytics-dimension-repository_id76627300
octolytics-dimension-repository_nwocontentstack/contentstack-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id76627300
octolytics-dimension-repository_network_root_nwocontentstack/contentstack-javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released5b34a4e4898b066c629879feb4b184bc471d6a7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/contentstack/contentstack-javascript/issues/41#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcontentstack%2Fcontentstack-javascript%2Fissues%2F41
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcontentstack%2Fcontentstack-javascript%2Fissues%2F41
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=contentstack%2Fcontentstack-javascript
Reloadhttps://github.com/contentstack/contentstack-javascript/issues/41
Reloadhttps://github.com/contentstack/contentstack-javascript/issues/41
Reloadhttps://github.com/contentstack/contentstack-javascript/issues/41
contentstack https://github.com/contentstack
contentstack-javascripthttps://github.com/contentstack/contentstack-javascript
Notifications https://github.com/login?return_to=%2Fcontentstack%2Fcontentstack-javascript
Fork 24 https://github.com/login?return_to=%2Fcontentstack%2Fcontentstack-javascript
Star 33 https://github.com/login?return_to=%2Fcontentstack%2Fcontentstack-javascript
Code https://github.com/contentstack/contentstack-javascript
Issues 1 https://github.com/contentstack/contentstack-javascript/issues
Pull requests 3 https://github.com/contentstack/contentstack-javascript/pulls
Actions https://github.com/contentstack/contentstack-javascript/actions
Projects 0 https://github.com/contentstack/contentstack-javascript/projects
Security 0 https://github.com/contentstack/contentstack-javascript/security
Insights https://github.com/contentstack/contentstack-javascript/pulse
Code https://github.com/contentstack/contentstack-javascript
Issues https://github.com/contentstack/contentstack-javascript/issues
Pull requests https://github.com/contentstack/contentstack-javascript/pulls
Actions https://github.com/contentstack/contentstack-javascript/actions
Projects https://github.com/contentstack/contentstack-javascript/projects
Security https://github.com/contentstack/contentstack-javascript/security
Insights https://github.com/contentstack/contentstack-javascript/pulse
New issuehttps://github.com/login?return_to=https://github.com/contentstack/contentstack-javascript/issues/41
New issuehttps://github.com/login?return_to=https://github.com/contentstack/contentstack-javascript/issues/41
#42https://github.com/contentstack/contentstack-javascript/pull/42
UnhandledPromiseRejection thrown from within SDKhttps://github.com/contentstack/contentstack-javascript/issues/41#top
#42https://github.com/contentstack/contentstack-javascript/pull/42
https://github.com/viglucci
https://github.com/viglucci
vigluccihttps://github.com/viglucci
on Jan 20, 2021https://github.com/contentstack/contentstack-javascript/issues/41#issue-789510428
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.