Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using v5.3 with typescript > 4.3.x brings error "Cannot read properties of undefined (reading '_initOracleClient')" #1462

Closed
maku opened this issue Feb 24, 2022 · 5 comments

Comments

@maku
Copy link

maku commented Feb 24, 2022

  1. What versions are you using?

Give your database version:
Oracle Database 18c Standard Edition 2 Release 18.0.0.0.0 - Production

Also run Node.js and show the output of:

process.platform win32
process.version: v16.13.0
process.arch: x64

node dependency "oracledb": "5.3.0"
  1. Is it an error or a hang or a crash?

    error

  2. What error(s) or behavior you are seeing?

oracledb.js -> function initOracleClient -> Line 144 this is undefined

Uncaught TypeError: Cannot read properties of undefined (reading '_initOracleClient')

The same functionality works with typescript <= 4.3.x, with typescript >= 4.4 I get the error

example typescript code:

import { ConnectionAttributes, initOracleClient, Connection, getConnection } from 'oracledb';
...
initOracleClient({ libDir: process.env[ORACLE_CLIENT_LIBDIR] });
@maku maku added the bug label Feb 24, 2022
@cjbj
Copy link
Member

cjbj commented Feb 24, 2022

@maku
Copy link
Author

maku commented Feb 24, 2022

@cjbj I do not understand. When I remove the import of "initOracleClient" I am not able to compile the typescript code....

@cjbj
Copy link
Member

cjbj commented Feb 25, 2022

You could help us by:

  • doing a bit of testing and removing the import and use of initOracleClient. Just set PATH to the Oracle Client directory. Does that work?
  • Sharing an actually runnable script of about 10-15 lines that shows the problem.

@cjbj
Copy link
Member

cjbj commented Feb 25, 2022

@maku never mind; I just spent some Saturday time and reproduced it. @anthony-tuininga supplied a patch that resolves it for us.

--- a/lib/oracledb.js
+++ b/lib/oracledb.js
@@ -105,6 +105,7 @@ class OracleDb {
     this.createPool = nodbUtil.callbackify(createPool).bind(_oracledb);
     this.shutdown = nodbUtil.callbackify(shutdown).bind(_oracledb);
     this.startup = nodbUtil.callbackify(startup).bind(_oracledb);
+    this.initOracleClient = this.initOracleClient.bind(_oracledb);
   }
 
   // temporary method for determining if an object is a date until

Try putting that in a .patch file installed via a postInstall script in your package.json, see #1391 (comment).

Thanks for reporting the issue.

@cjbj
Copy link
Member

cjbj commented Aug 12, 2022

Closing the issue. The fix was in the node-oracledb 5.4 release from back in June. Thanks for reporting it.

@cjbj cjbj closed this as completed Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants