Gcloud initialized to wrong project - linux

When trying to run my Nodejs application which uses the Google-Cloud-Video-Intelligence API, I am getting an error:
(node:20730) UnhandledPromiseRejectionWarning: Error: 7 PERMISSION_DENIED: Cloud Video Intelligence API has not been used in project firebase-cli before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/videointelligence.googleapis.com/overview?project=firebase-cli then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
at new createStatusError (/home/warcram/node_modules/grpc/src/client.js:64:15)
at /home/warcram/node_modules/grpc/src/client.js:583:15
(node:20730) 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: 1)
(node:20730) [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.e
Now, this would be fixable if I was using the firebase-cli project, however this has since been deleted. I am now trying to use a separate project. I used gcloud init in the same directory for the new project, however when running the application I still get the same errors.
Is there anyway that I can uninitialize the firebase-cli project and continue with my new one?
Many thanks

Figured the issue out, I needed to set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the initialization json file. I did this and my program worked using the correct project. Thanks for any views, hope this helps in the future.

Related

Azure Bot is not Responding On Teams

I have a bot built with Microsoft Bot framework Node.JS SDK, the bot is deployed on a windows server and has been working well for over a year.
Just a few days ago, the Bot stopped responding, checked the bot's log and came across this error.
node:14628) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:14628) UnhandledPromiseRejectionWarning: Error: BotFrameworkAdapter.processActivity(): 400 ERROR
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (C:\inetpub\wwwroot\BotServiceToken\node_modules\botbuilder\lib\botFrameworkAdapter.js:1262:37)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:482:12)
at endReadableNT (_stream_readable.js:1221:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at BotFrameworkAdapter.<anonymous> (C:\inetpub\wwwroot\BotServiceToken\node_modules\botbuilder\lib\botFrameworkAdapter.js:687:27)
at Generator.throw (<anonymous>)
at rejected (C:\inetpub\wwwroot\BotServiceToken\node_modules\botbuilder\lib\botFrameworkAdapter.js:12:65)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:14628) 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)
(node:14628) [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.
Note: The bot works well when I test with the Botframework Emulator.
Is there a way to solve this, I have checked the botFrameworkAdapter.js file mentioned in the error but I can't seem to find the bug.
Just like the warning said
DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
To avoid the depreciation warning. You need to find out the new Buffer() methods in your codes and replace them with a new one.

Protractor: how to debug unhandled Promise Rejections?

After a huge PR, our E2E has started taking almost 4 hours to execute.
Reading the log, I've found the following line:
(node:6600) 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)
The official docs did not bring any information, so I've found this doc, that says:
--unhandled-rejections strict mode causes an uncaught exception
The question is:
is there any way to use this flag with Protractor? Or how can I debug to find this exception?

I got an error while running dist file in nestjs project, please help me

(node:8356) UnhandledPromiseRejectionWarning: Error: No type definitions were found with the specified file name patterns: "./**/*.graphql". Please make sure there is at least one file that matches the given patterns.
at GraphQLTypesLoader.<anonymous> (E:\NestJS\Template_Login\teample-api-backend-nestjs\backend\node_modules\#nestjs\graphql\dist\graphql-types.loader.js:38:23)
at Generator.next (<anonymous>)
at fulfilled (E:\NestJS\Template_Login\teample-api-backend-nestjs\backend\node_modules\tslib\tslib.js:114:62)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:8356) 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: 1)
(node:8356) [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.
I ran into the same issue. This is most likely caused by the fact that the .graphql files are ignored in build time and not copied to /dist. Interestingly, I didn't have that before and the build seemed to complete just fine, it appeared only today.
I found a workaround to the problem proposed by the NestJS creator:
https://github.com/nestjs/graphql/issues/135
https://docs.nestjs.com/cli/monorepo#assets
There is assets option in nestjs.
This is the right way to do it in nestjs.

Google Cloud Functions Node.js Error Reporting - Unhandled Rejections not being logged

I have a Node.js Cloud Function and am trying to be alerted to unhandled rejections. If I throw an unhandled rejection and cause a crash in my index.js entry point, the error shows up in Error Reporting (although I don't receive a notification for some reason). This also shows up as log level "critical":
If I throw an identical unhandled rejection in a different .js file in the same Cloud Function (which is being imported by index.js), it does not show up as log level "critical" and the error is never reported in Error Reporting:
What is the correct way to ensure I capture all unhandled rejections across my entire Cloud Function (and ensure I receive alerts)? This is how I am initializing Error Reporting in my index.js entry point:
const {ErrorReporting} = require('#google-cloud/error-reporting');
const errors = new ErrorReporting({
reportUnhandledRejections: true
});
I got clarification from the Error Reporting team per this github issue: https://github.com/googleapis/nodejs-error-reporting/issues/548.
In the end, it was likely because I was only initializing my error reporting object in my main index.js and not passing it to or doing so again in my other .js files (where the actual unhandled rejections were occurring). One workaround was wrapping my entire index.js code in a try / catch(e) and in the catch(e) block put in errors.report(e). Then, even if an unhandled rejection occurs in another file during execution, I get notified in Error Reporting.

Discord.js Bot [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted Error

I'm having issues with Discord.js Bot on v13+. I'm getting [DISALLOWED_INTENTS] error. How can I fix this? Thanks.
(node:16060) UnhandledPromiseRejectionWarning: Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted. at WebSocketManager.createShards (C:\Users\schne\Desktop\Zeltux_v1.5.2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:260:15)
[05:24:04] (node:16060) 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: 1)
[05:24:04] (node:16060) [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.
As the error suggests, [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted, you're probably using an intent that hasn't been enabled.
Gateway Intents were introduced to the library in v12 and allow you to pick which events your bot will receive. Intents are groups of pre-defined events that the discord.js client will conditionally subscribe to. For example, omitting the DIRECT_MESSAGE_TYPING intent would prevent the discord.js client from receiving any typing events from direct messages.
You'll have to go to Discord Developer Portal, choose your application, go to the Bot section, and enable all the intents. (Or the ones you are using.)

Resources