Error while creating pdf from JS Report - pdf-generation

I am trying to create pdf with Js report but its giving error,The code I used is
In View:
<h1>Test Application</h1><h1>Test data</h1>
In Controller:
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult CreatePdf()
{
HttpContext.JsReportFeature().Recipe(Recipe.ElectronPdf);
return View("Index1");
}
And In startup.cs
services.AddMvc();
services.AddJsReport(new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.AsUtility()
.Create());
and I have installed these three versions jsreport.AspNetCore -Version 1.0.1 and jsreport.Local -Version 1.1.2 and jsreport.Binary -Version 1.10.0
The error is:
An unhandled exception occurred while processing the request.
JsReportBinaryException: Error rendering report: instance has been
daemonized and initialized successfully (pid: 6056)rendering has
finished with errors:Error: An error occurred while trying to execute
the command: at onCriticalError ([eval]:29603:25) at [eval]:29558:13
at tryCatcher ([eval]:36038:23) at Promise._settlePromiseFromHandler
([eval]:34061:31) at Promise._settlePromise ([eval]:34118:18) at
Promise._settlePromise0 ([eval]:34163:10) at Promise._settlePromises
([eval]:34238:18) at Async._drainQueue ([eval]:31008:16) at
Async._drainQueues ([eval]:31018:10) at Immediate.Async.drainQueues
[as _onImmediate] ([eval]:30892:14) at processImmediate [as
_immediateCallback] (timers.js:396:17) {"originalError":{"remoteStack":"Error: Command failed:
C:\Users\swapnil\AppData\Local\Temp\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\phantomjs.exe
--ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\swapnil\AppData\Local\Temp\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js
C:\Users\swapnil\AppData\Local\Temp\2\jsreport\6df52490-68bd-11e8-95df-47fc0392390csettings.html\n\n
at ChildProcess.exithandler (child_process.js:214:12)\n at emitTwo
(events.js:87:13)\n at ChildProcess.emit (events.js:172:7)\n at
maybeClose (internal/child_process.js:854:16)\n at
Process.ChildProcess._handle.onexit
(internal/child_process.js:222:5)"}}(Original) Error: Error during
rendering report: Command failed:
C:\Users\swapnil\AppData\Local\Temp\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\phantomjs.exe
--ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\swapnil\AppData\Local\Temp\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js
C:\Users\swapnil\AppData\Local\Temp\2\jsreport\6df52490-68bd-11e8-95df-47fc0392390csettings.html
at [eval]:36644:23 at ConcatStream. ([eval]:42366:43) at
emitNone (events.js:72:20) at ConcatStream.emit (events.js:166:7) at
finishMaybe ([eval]:4229:14) at afterWrite ([eval]:4115:3) at
nextTickCallbackWithManyArgs (node.js:486:18) at process._tickCallback
(node.js:384:17) {"remoteStack":"Error: Command failed:
C:\Users\Computer\AppData\Local\Temp\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\phantomjs.exe
--ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\Computer\AppData\Local\Temp\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js
C:\Users\Computer\AppData\Local\Temp\2\jsreport\6df52490-68bd-11e8-95df-47fc0392390csettings.html\n\n
at ChildProcess.exithandler (child_process.js:214:12)\n at emitTwo
(events.js:87:13)\n at ChildProcess.emit (events.js:172:7)\n at
maybeClose (internal/child_process.js:854:16)\n at
Process.ChildProcess._handle.onexit
(internal/child_process.js:222:5)"}

I solved this by using
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult CreatePdf()
{
HttpContext.JsReportFeature().Recipe(Recipe.ElectronPdf);
return PartialView("Index1");
}

In 2021 i have updated the jsreport.Binary from (2.9.0) to (2.11.0) and the error was gone.
Thanks

Related

Heroku vite issue laravel 9

enter image description here
vite v2.9.14 dev server running at:
Local: http://localhost:3000/
Network: use --host to expose
ready in 309ms.
Laravel v9.19.0
APP_URL: http://localhost
node:internal/errors:465 timing config:load:flatten Completed in 5ms
ErrorCaptureStackTrace(err);
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/app/vendor/league/commonmark/src/Extension/CommonMark/Delimiter/Processor'
at FSWatcher. (node:internal/fs/watchers:244:19)
at Object.watch (node:fs:2264:34)
at createFsWatchInstance (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:45537:17)
at setFsWatchListener (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:45584:15)
at NodeFsHandler$1._watchWithNodeFs (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:45739:14)
at NodeFsHandler$1._handleDir (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:45975:19)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async NodeFsHandler$1._addToNodeFs (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:46025:16)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:47233:10)
at NodeFsHandler$1._addToNodeFs (/app/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:46053:18)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/app/vendor/league/commonmark/src/Extension/CommonMark/Delimiter/Processor',
filename: '/app/vendor/league/commonmark/src/Extension/CommonMark/Delimiter/Processor'
}

GraphQL build error when deploying at Vercel

I'm trying to deploy my Nextjs app to Vercel, I am using strapi backend deployed at Heroku...
Unfortunately I am stuck at this build error at Vercel....
I have googled and tried to find a solution but unfortunately I can't and have no idea what to do.
Any ideas appreciated....
> Build error occurred
Error: Unexpected token M in JSON at position 0
at new ApolloError (/vercel/path0/node_modules/#apollo/client/errors/errors.cjs:34:28)
at /vercel/path0/node_modules/#apollo/client/core/core.cjs:1595:19
at both (/vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:986:53)
at /vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:979:72
at new Promise (<anonymous>)
at Object.then (/vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:979:24)
at Object.error (/vercel/path0/node_modules/#apollo/client/utilities/utilities.cjs:987:49)
at notifySubscription (/vercel/path0/node_modules/zen-observable/lib/Observable.js:140:18)
at onNotify (/vercel/path0/node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.error (/vercel/path0/node_modules/zen-observable/lib/Observable.js:240:7) {
type: 'ApolloError',
graphQLErrors: [],
clientErrors: [],
networkError: {
name: 'ServerParseError',
response: { size: 0, timeout: 0 },
statusCode: 405,
bodyText: 'Method Not Allowed'
}
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1

Laravel Spatie Browsershot errno: -4058, code: 'ENOENT'

I am trying to capture a screenshot of my website running in localhost and i am using Spatie/Browsershot.
When i try to run this function
public function receipt(){
$image = Browsershot::url('http://localhost:8000/transaction/receipt/123')
->setNodeBinary('C:\Users\\my_user\\nodejs\\node.exe')
->setNpmBinary('C:\Users\\my_user\\nodejs\\npm.exe')
->base64Screenshot();
return $image;
}
This error popped up
Symfony\Component\Process\Exception\ProcessFailedException
The command "C:^\Users^\Abimanyu^\nodejs^\node.exe ^"D:^\laravel_projects^\teliti-core-app^\vendor^\spatie^\browsershot^\src/../bin/browser.js^" ^"^{^\^"url^\^":^\^"http:^\/^\/localhost:8000^\/transaction^\/receipt^\/123^\^",^\^"action^\^":^\^"screenshot^\^",^\^"options^\^":^{^\^"type^\^":^\^"png^\^",^\^"args^\^":^[^],^\^"viewport^\^":^{^\^"width^\^":800,^\^"height^\^":600^},^\^"executablePath^\^":^\^"C:^\^\Users^\^\Abimanyu^\^\AppData^\^\Local^\^\Google^\^\Chrome^\^\Application^\^\chrome.exe^\^"^}^}^"" failed. Exit Code: 1(General error) Working directory: D:\laravel_projects\teliti-core-app\public Output: ================ Error Output: ================ [Error: ENOENT: no such file or directory, mkdtemp 'undefined\temp\puppeteer_dev_chrome_profile-XXXXXX'] { errno: -4058, code: 'ENOENT', syscall: 'mkdtemp', path: 'undefined\\temp\\puppeteer_dev_chrome_profile-XXXXXX' }
I've tried setting the custom path to these attributes:
setChromePath("C:\Users\my_user\AppData\Local\Google\Chrome\Application\chrome.exe")
setNpmBinary('C:\Users\my_user\AppData\Roaming\npm')
I've also run npm install puppeteer.
Additional :
Laravel 8
Windows 10
Node v14.17.2
Anyone any ideas on what i am doing wrong?

Cannot run semantic-release-cli setup for GitHub action

When running npx semantic-release-cli setup with GitHub Actions for my public repository https://github.com/henrycity/movie-browser-frontend, I got this error
ERR! semantic-release RequestError: Error: Invalid URI "undefined/repos/henrycity/movie-browser-frontend/actions/secrets/public-key"
ERR! semantic-release at new RequestError (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request-promise-core/lib/errors.js:14:15)
ERR! semantic-release at Request.plumbing.callback (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request-promise-core/lib/plumbing.js:87:29)
ERR! semantic-release at Request.RP$callback [as _callback] (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request-promise-core/lib/plumbing.js:46:31)
ERR! semantic-release at self.callback (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request/request.js:185:22)
ERR! semantic-release at Request.emit (events.js:315:20)
ERR! semantic-release at Request.init (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request/request.js:273:17)
ERR! semantic-release at Request.RP$initInterceptor [as init] (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request-promise-core/configure/request2.js:45:29)
ERR! semantic-release at new Request (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request/request.js:127:8)
ERR! semantic-release at request (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request/index.js:53:10)
ERR! semantic-release at /Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/node_modules/request/index.js:100:12
ERR! semantic-release at createSecret (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/src/lib/github-actions.js:36:28)
ERR! semantic-release at module.exports (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/src/lib/github-actions.js:83:9)
ERR! semantic-release at module.exports (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/src/lib/ci.js:50:17)
ERR! semantic-release at processTicksAndRejections (internal/process/task_queues.js:97:5)
ERR! semantic-release at module.exports (/Users/tri.tran/.nvm/versions/node/v12.18.3/lib/node_modules/semantic-release-cli/src/index.js:90:5)
I tried to log the info object in https://github.com/semantic-release/cli/blob/master/src/lib/ci.js. I notice that info.github.endpoint is undefined, which causes the error.
giturl: 'https://github.com/henrycity/movie-browser-frontend.git',
ghrepo: { slug: [ 'henrycity', 'movie-browser-frontend', '' ] },
npm: {
registry: 'https://npm.pkg.github.com/',
authmethod: 'token',
username: 'henrycity',
password: 'xxxx,
token: 'xxxx'
},
github: { token: 'xxxx }
Version: 5.4.1
I wonder what causes the error.
The issue is fixed in version 5.4.3.

TypeError: Cannot read property 'minify' of undefined

So, since yesterday I've started getting the following build errors when attempting to deploy my project to either Heroku or Now. Locally, the project works completely fine. What's the issue here and how do I resolve it?
On Now the logs read as follows:
02/04 10:38 AM (7m)
Error: static/chunks/commons.2ab19e066e0721785714.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/minify.js:162:59)
at TaskRunner.boundWorkers (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:62:41)
at enqueue (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:82:14)
at tryCatcher (/tmp/3d5396dc/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:690:18)
at _drainQueueStep (/tmp/3d5396dc/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/tmp/3d5396dc/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/tmp/3d5396dc/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues (/tmp/3d5396dc/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
at Function.buildError (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/index.js:111:14)
at results.forEach (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/index.js:255:50)
at Array.forEach (<anonymous>)
at taskRunner.run (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/index.js:242:17)
at step (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:76:9)
at done (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:84:30)
at boundWorkers (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:89:13)
at TaskRunner.boundWorkers (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:64:11)
at enqueue (/tmp/3d5396dc/node_modules/terser-webpack-plugin/dist/TaskRunner.js:82:14)
at tryCatcher (/tmp/3d5396dc/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/tmp/3d5396dc/node_modules/bluebird/js/release/promise.js:690:18)
at _drainQueueStep (/tmp/3d5396dc/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/tmp/3d5396dc/node_modules/bluebird/js/release/async.js:131:9) Error: static/runtime/webpack-42652fa8b82c329c0559.js from Terser
And on Heroku they read as:
2019-02-04T10:58:23.286953+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:23:31)
2019-02-04T10:58:23.286955+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:1337:18)
2019-02-04T10:58:23.286956+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:23:31) code: 'MODULE_NOT_FOUND' }
2019-02-04T10:58:23.287670+00:00 app[web.1]: (node:30) UnhandledPromiseRejectionWarning: Error: Cannot find module 'graphql-tools'
2019-02-04T10:58:23.287672+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
2019-02-04T10:58:23.287674+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:507:25)
2019-02-04T10:58:23.287675+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:637:17)
2019-02-04T10:58:23.287676+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:22:18)
2019-02-04T10:58:23.287678+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/index.js:2110:18)
2019-02-04T10:58:23.287679+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/index.js:23:31)
2019-02-04T10:58:23.287680+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/index.js:341:31)
2019-02-04T10:58:23.287681+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/index.js:23:31)
2019-02-04T10:58:23.287682+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/index.js:1337:18)
2019-02-04T10:58:23.287683+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/index.js:23:31)
2019-02-04T10:58:23.287772+00:00 app[web.1]: (node:30) 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(). (rejection id: 133)
2019-02-04T10:59:23.314730+00:00 app[web.1]: { Error: Cannot find module 'graphql-tools'
2019-02-04T10:59:23.314741+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
2019-02-04T10:59:23.314743+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:507:25)
2019-02-04T10:59:23.314745+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:637:17)
2019-02-04T10:59:23.314746+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:22:18)
2019-02-04T10:59:23.314748+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:2110:18)
2019-02-04T10:59:23.314750+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:23:31)
2019-02-04T10:59:23.314752+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:341:31)
2019-02-04T10:59:23.314753+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:23:31)
2019-02-04T10:59:23.314755+00:00 app[web.1]: at Object.<anonymous> (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:1337:18)
2019-02-04T10:59:23.314756+00:00 app[web.1]: at __webpack_require__ (/app/.next/server/static/KANAUI~IRZ6dj1SV~XfmF/pages/_app.js:23:31) code: 'MODULE_NOT_FOUND' }
This issue has been fixed a short time ago:
https://github.com/webpack-contrib/terser-webpack-plugin/issues/66
The reason why it worked locally is because you might have had the old version still cached.

Resources