Nextjs displays white screen during development - next.js

When I run yarn dev I get the following error
(node:171412) UnhandledPromiseRejectionWarning: TypeError: Cannot set
property 'status' of undefined at
xxx\my-next-app\node_modules\next\dist\server\hot-reloader.js:16:94 at
async Promise.all (index 0) at async DynamicEntryPlugin.config.entry
(xxx\my-next-app\node_modules\next\dist\server\hot-reloader.js:15:96)
(Use node --trace-warnings ... to show where the warning was
created) (node:171412) 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: 32)
I have been unable to figure out the issue
My next version is ^10.0.4

Related

node-oracledb on M1 Mac

I'm trying to connect to my university's Oracle DB. I wrote a simple backend that is working on my Windows machine but I can't get it working on my M1 Mac. You can find my repo here and here is the core of it,
const express = require('express');
const oracledb = require('oracledb');
if (process.platform === 'darwin') {
try {
console.log("Success");
oracledb.initOracleClient({libDir: process.env.HOME + '/Downloads/instantclient_19_8'});
} catch (err) {
console.log("Failure");
console.error('Whoops!');
console.error(err);
process.exit(1);
}
}
const dotenv = require('dotenv');
const app = express();
const PORT = 5000;
dotenv.config();
var cors = require('cors');
app.use(cors());
app.use(express.json());
app.listen(PORT, ()=>{console.log(`listen to port ${PORT}`);})
database_initialized = false
async function init_database() {
// The following should be wrapped in a try/catch
await oracledb.createPool({
user: process.env.USER_NAME,
password: process.env.DB_PASSWORD,
connectionString: process.env.CONNECTION_STRING
});
console.log("Successfully created connection pool");
database_initialized = true
}
app.get('/', (req,res) => {
res.send('Hello world!');
});
app.get('/get-customers', (req,res) => {
async function fetchDataCustomers(){
try {
const connection = await oracledb.getConnection();
oracledb.outFormat = oracledb.OUT_FORMAT_ARRAY;
const query = process.env.QUERY_STR;;
const result = await connection.execute(query);
console.log("Completed request");
try {
await connection.close();
}
catch (err) {
console.log("Encountered an error closing a connection in the connection pool.");
}
return result;
} catch (error) {
return error;
}
}
fetchDataCustomers().then(dbRes => {
res.send(dbRes);
})
.catch(err => {
res.send(err);
})
})
init_database();
I found someone who was nice enough to provide detailed instructions on using Rosetta to switch to the x64 version nvm, but my oracledb.createPool() function doesn't seems to be working on my M1 Mac (this works on my Windows machine). By that I mean the try block fails and drops to the catch block and prints "listen to port 5000" followed by repeatedly printing the console.log message. There are no other errors messages printed to the terminal.
On my M1 Mac, I follow the linked instructions and run nvm use intel and node -e 'console.log(process.arch)' to verify I'm using x64. On both machines, I can then run:
npm init -y
npm i --save express
npm i --save-dev nodemon dotenv oracledb cors
and node server.js to test the connection.
On my Windows machine, I connect and can then go on to check the endpoint I created (not included here but can be seen in the github repo I linked above). On my M1 Mac, I just get the message in the catch block telling me that an error was encountered. I want to be able to connect to an Oracle DB from my M1 Mac but it seems I don't yet have the skills to figure it out on my own. Any help would be appreciated.
Update:
After pulling oracledb.createPool() out of the try/catch I got the following:
listen to port 5000
(node:47913) UnhandledPromiseRejectionWarning: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 0x0001): tried: 'libclntsh.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (errno=62), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file, not in dyld cache), 'libclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (errno=62), '/usr/lib/libclntsh.dylib' (no such file, not in dyld cache)". See https://oracle.github.io/node-oracledb/INSTALL.html for help
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have the 64-bit Oracle Instant Client Basic or Basic Light package libraries in
/usr/local/lib or set by calling oracledb.initOracleClient({libDir: "/my/instant_client_directory"}).
Oracle Instant Client can be downloaded from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async init_database (/Users/my-name/workspaces/node-oracle-test-project/back-end/server.js:30:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:47913) 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:47913) [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 then re-ran npm install oracledb and I'm getting
oracledb ********************************************************************************
oracledb ** Node-oracledb 5.5.0 installed in Node.js 19.3.0 (darwin, x64)
oracledb **
oracledb ** To use node-oracledb:
oracledb ** - Oracle Client libraries (64-bit) must be available.
oracledb ** - Follow the installation instructions:
oracledb ** https://oracle.github.io/node-oracledb/INSTALL.html#instosx
oracledb ********************************************************************************
So I'm following the link and trying to find how to install Oracle Client libraries.
I'm following the instructions here but I'm not sure how to proceed. I ran /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh as it says but I'm not where to move instantclient_19_8 so that it's accessible. I tried moving instantclient_19_8 to /Users/brian but that didn't resolve the error message.
I found this and added the suggested conditional to my code. Getting a new error.
(node:51947) UnhandledPromiseRejectionWarning: Error: ORA-24415: Missing or null username.
at async init_database (/Users/brian/workspaces/node-oracle-test-project/back-end/server.js:42:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:51947) 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:51947) [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.
Is there a solution? Will I just resolve one error to be greeted by another? Am I just wasting my time?
After pulling oracledb.createPool() out of the try/catch I got the following:
listen to port 5000
(node:47913) UnhandledPromiseRejectionWarning: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 0x0001): tried: 'libclntsh.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (errno=62), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file, not in dyld cache), 'libclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (errno=62), '/usr/lib/libclntsh.dylib' (no such file, not in dyld cache)". See https://oracle.github.io/node-oracledb/INSTALL.html for help
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have the 64-bit Oracle Instant Client Basic or Basic Light package libraries in
/usr/local/lib or set by calling oracledb.initOracleClient({libDir: "/my/instant_client_directory"}).
Oracle Instant Client can be downloaded from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async init_database (/Users/my-name/workspaces/node-oracle-test-project/back-end/server.js:30:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:47913) 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:47913) [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 then re-ran npm install oracledb and I'm got
oracledb ********************************************************************************
oracledb ** Node-oracledb 5.5.0 installed in Node.js 19.3.0 (darwin, x64)
oracledb **
oracledb ** To use node-oracledb:
oracledb ** - Oracle Client libraries (64-bit) must be available.
oracledb ** - Follow the installation instructions:
oracledb ** https://oracle.github.io/node-oracledb/INSTALL.html#instosx
oracledb ********************************************************************************
I followed the instructions here to install Instant Client but actually found this to easier to follow (because I stopped reading the doc once I thought I got what I needed). There is an issue with getting my credentials from my .env that I need to figure out but I'd consider that to be out of scope to my original post. This will work so long as the process.env values are hard coded. (I know. Fixing that is the next step.) I will update the GitHub repo I linked in the original post and hopefully others will find things easier than I did.
Update: The .env issue turned out to be an issue with where I was storing it. On my Windows machine I was able to put it in the parent directory (sibling to my .gitignore) but on my Mac I had to put it in the back-end directory.

Error to DEPLOY next.js 13 with Firebase: TypeError: Cannot read properties of null (reading 'toString')

i'm in trouble to connect Firebase to next 13, already search for it on internet and a lot of people had similar problems
Error:
[debug] [2023-02-08T18:54:22.084Z] TypeError: Cannot read properties of null (reading 'toString')
at ɵcodegenFunctionsDirectory (C:\Users\idieg\AppData\Roaming\npm\node_modules\firebase-tools\lib\frameworks\next\index.js:222:18)
at async prepareFrameworks (C:\Users\idieg\AppData\Roaming\npm\node_modules\firebase-tools\lib\frameworks\index.js:306:84)
at async deploy (C:\Users\idieg\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\index.js:53:13)
[error]
[error] Error: An unexpected error has occurred.
also like to clarify that i already can emulate this without bugs and also ran the firebase experiments:enable webframeworks but i need to deploy it.

How to run Pub-Sub functions in Firebase Functions shell

I'm unable to run my pub-sub triggers in local Cloud Functions Shell. I've created Cloud Functions in the following way:
export const sendNotifications = functions.pubsub.schedule('0 10 * * *').timeZone('Asia/Kolkata').onRun(async (context) => {
console.log('running sendNotificationForActivities');
await sendMessages();
return 0;
}
As mentioned here, I try to run firebase functions:shell from my system followed by:
> sendNotifications({data: new Buffer('{"hello":"world"}'), attributes: {foo: 'bar'}})
or
> sendNotifications({})
and other variants. Following is the error stack trace I received:
firebase > sendNotificationForActivities({})
'Successfully invoked function.'
firebase > ⚠ TypeError: Cannot read property 'params' of undefined
at cloudFunction (/Users/mayurdhurpate/code/pruoo_app/backend_admin/functions/node_modules/firebase-functions/lib/cloud-functions.js:109:38)
at Run (/Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:458:20)
at /Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:442:19
at Generator.next (<anonymous>)
at /Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:3:12)
at Run (/Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:435:12)
at /Users/mayurdhurpate/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:457:15
at Generator.next (<anonymous>)
⚠ Your function was killed because it raised an unhandled error.
I think I might be missing a required params field but I couldn't find the right way to enter the parameters. I'm using firebase-tools#7.1.1 on MacOS.
I have the same error.
The error is located in cloud-functions.js:117:28.
He is trying to access a key of context even if context does not exist.
I updated to the newest version but the error still persists.
As workaround I added this code at line 89 in cloud-functions.js: context = context || {};
This solves the error and I can use the firebase shell.
I hope this nasty hack helps.
Until Google fixes their code or updates the documentation.
Dominik

React Native FCM push notification token null

I'm working on a React Native project and i need to set up push notifications on iOS and Android ends using react-native-fcm,
When i try to get a token it return null in Android and the following error on iOS:
Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'requestPermissions' of undefined
TypeError: Cannot read property 'requestPermissions' of undefined
at Object.FCM.requestPermissions (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:143309:27)
at PushNotificationController.componentDidMount$ (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:143144:58)
at tryCatch (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:16751:19)
at Generator.invoke [as _invoke] (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:16924:24)
at Generator.prototype.(anonymous function) [as next] (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:16794:23)
at tryCatch (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:16751:19)
at invoke (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:16827:22)
at blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:16855:13
at tryCallTwo (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:3524:7)
at doResolve (blob:http://localhost:8081/4a6e4d63-516d-4288-ac74-d1494e78d48f:3688:15)
Thanks for responding and i'm available for further information.

Meteor constantly crashing: Error: write after end

My meteor instance is crashing after every refresh I do. Interestingly it does not happen when I run it inside a docker container.
=> App running at: http://localhost:3000/
events.js:141
throw er; // Unhandled 'error' event
^
Error: write after end
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:430:15)
at IncomingMessage.ondata (_stream_readable.js:542:20)
at emitOne (events.js:77:13)
at IncomingMessage.emit (events.js:169:7)
at IncomingMessage.Readable.read (_stream_readable.js:368:10)
at flow (_stream_readable.js:759:26)
at resume_ (_stream_readable.js:739:3)
at nextTickCallbackWith2Args (node.js:458:9)
at process._tickCallback (node.js:372:17)
Any idea how I could further debug this issue?

Resources