Uncaught ReferenceError: BroadcastChannel is not defined - deno

Trying to run deno locally for a deno deploy app which supports broadcast channel but getting this compilation error how do I fix it?
const channel = new BroadcastChannel('')
Uncaught ReferenceError: BroadcastChannel is not defined

It's in the stable docs for v1.17.1, so shouldn't need --unstable to use it:
https://doc.deno.land/deno/stable#v1.17.1/~/BroadcastChannel
Compare with unstable: https://doc.deno.land/deno/unstable#v1.17.1
However, in reality that's not the case:
$ deno
Deno 1.17.1
exit using ctrl+d or close()
> new BroadcastChannel()
Uncaught ReferenceError: BroadcastChannel is not defined
at <anonymous>:2:1
> close()
$ deno --unstable
Deno 1.17.1
exit using ctrl+d or close()
> new BroadcastChannel()
Uncaught TypeError: Failed to construct 'BroadcastChannel': 1 argument required, but only 0 present.
at Object.requiredArguments (deno:ext/webidl/00_webidl.js:627:13)
at new BroadcastChannel (deno:ext/broadcast_channel/01_broadcast_channel.js:81:14)
at <anonymous>:2:1
> close()
You can file an issue in the repo.
Edit: Issue created: denoland/deno#13214

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.

dyld: Symbol not found: _SecTrustEvaluateWithError

I'm on MacPro OS 10.12 (can not be upgraded to 10.13 or beyond bc HW is old!) and I get below error.
Any help please
Thanks
Task start deno run -A --watch=static/,routes/ dev.ts
Watcher Process started.
The manifest has been generated for 3 routes and 1 islands.
Server listening on http://localhost:3000
dyld: Symbol not found: _SecTrustEvaluateWithError
Referenced from: /Users/kemalgencay/Library/Caches/esbuild/bin/esbuild-darwin-
64#0.14.39
Expected in: flat namespace
An error occured during route handling or page rendering. Error: The service was
stopped
at https://deno.land/x/esbuild#v0.14.39/mod.js:1304:25
at https://deno.land/x/esbuild#v0.14.39/mod.js:633:9
at afterClose (https://deno.land/x/esbuild#v0.14.39/mod.js:611:7)
at https://deno.land/x/esbuild#v0.14.39/mod.js:1844:11
error: Uncaught (in promise) BrokenPipe: Broken pipe (os error 32)
Watcher Process finished. Restarting on file change...
"devDependencies": {
"esbuild-wasm":"latest"
},
"overrides": {
"esbuild":"npm:esbuild-wasm#latest"
}
Just add this to the package.json
And then run: npm install
Hope it helps!

Moment.js with $ undefined

When package is installed I receive '$ is undefined' from ender.js within the node_modules.
Is moment working with any additional dependencies or what am I missing?
Thanks
edit: Error is received when I run webdriver with cucumber.

App is broken after 0.9.4 update: undefined is not a function in dynamic_template.js:371

I had a meteor 0.9.3 app that was working.
I ran meteor update. Now I have a bunch or errors (60 total):
Uncaught TypeError: undefined is not a function dynamic_template.js:371
Uncaught TypeError: Cannot read property 'prototype' of undefined helpers.js:140
Uncaught TypeError: undefined is not a function router.js:61
Uncaught TypeError: Cannot read property 'RouteController' of undefined iron-router-progress.js?2b52a697e5a2fba4ec827721c08cfdd0a5bae508:25
Uncaught TypeError: Cannot read property 'RouteController' of undefined global-imports.js?a26cc176b56b3d2b1df619ec7af99630b0fb6a1f:3
Uncaught ReferenceError: Template is not defined template.about.js?3ead3e2cab8a60252235e31f2533c2179f736294:2
Uncaught ReferenceError: Template is not defined template.register.js?60e4180bd0193951fab290d41493f5036f66240d:2
... 53 more errors:
... mainly "Template is not defined" and "Meteor is not defined"
Line 371 of dynamic_template.js is the following:
UI.registerHelper('DynamicTemplate', Template.__create__('DynamicTemplateHelper', function () {
What's wierd is that if I try to go back with meteor update --release 0.9.3 or 0.9.2, I still have those errors. So I'm stuck, I have to fix those.
Another anoying thing is that everytime I start my meteor server, I get updating package catalog with a progress bar, and my server takes a while (~10s) to start up.
Any ideas?
In 0.9.4 there are changes to the templating API. See HISTORY.md on gihub/meteor/meteor for more details.
The fix for your immediate problem is to replace UI with Template
Template.registerHelper('DynamicTemplate', Template.__create__('DynamicTemplateHelper', function () {

Error after upgraded to Meteor 0.9.1

After upgraded Meteor from 0.9.0.1 to 0.9.1, I got the following errors in console:
Uncaught TypeError: Cannot read property 'registerHelper' of undefined
Uncaught TypeError: Cannot read property 'T9n' of undefined
Uncaught TypeError: Cannot read property 'AccountsEntry' of undefined
Uncaught ReferenceError: Template is not defined
Uncaught ReferenceError: Meteor is not define
Exception in defer callback: ReferenceError: Spacebars is not defined
It seems that the changes are not backwards compatible.
It sounds like you have a package that is not compatible. To check what this is look at your server console.
If you want to brute force your way into getting it to work, git clone the offending package into /packages and it should get it to work (also add it with meteor add xx where xx is the name of the directory in /packages
Additionally rename the following (even though you would not yet have to) to bring it up to date:
UI.registerHelper -> Template.registerHelper
Handlebars.registerHelper -> Template.registerHelper

Resources