TypeError: Cannot read properties of undefined (reading '0') using client.openSession();
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- next.js, node.js, sql, typescript
- 领域
- backend, build-system
调研方向
首先,使用 next.config.js 中的 webpack alias 重现 app/api/databricks-test/route.ts 的失败,然后将其与 examples/usage.js 进行比较。跟踪 openSession 经过 @databricks/sql 和 node-int64/Int64.js 的路径,并验证 lz4 workaround 不再导致 TypeError。当 session 成功打开、示例查询返回结果且 route-handler 的每个分支都返回 response 时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Previously working code causing a TypeError: Cannot read properties of undefined (reading '0'). This code is from the following example: https://github.com/databricks/databricks-sql-nodejs/blob/HEAD/examples/usage.js
const { DBSQLClient } = require('@databricks/sql');
import { DBSQLLogger, LogLevel } from '@databricks/sql';
import { NextResponse } from "next/server";
export async function POST(){
const logger = new DBSQLLogger({ filepath: 'log.txt', level: LogLevel.debug });
const client = new DBSQLClient({ logger: logger });
console.log("CREATED CLIENT");
client
.connect({
host: process.env.DATABRICKS_SERVER_HOSTNAME,
path: process.env.DATABRICKS_HTTP_PATH,
token: process.env.DATABRICKS_TOKEN,
})
.then(async (client: { openSession: () => any; close: () => any; }) => {
const session = await client.openSession();
console.log("SESSION CREATED");
const queryOperation = await session.executeStatement('SELECT "Hello, World!"');
const result = await queryOperation.fetchAll();
await queryOperation.close();
console.table(result);
await session.close();
await client.close();
return NextResponse.json(result);
})
.catch((error: any) => {
console.log(error);
if (error instanceof Error) {
console.error("Error executing query: ", error);
return NextResponse.json(
{ error: "Failed to execute query: ", details: error.message },
{ status: 500 }
);
}
});
}
Console output:
{"level":"info","message":"Created DBSQLClient"}
CREATED CLIENT
TypeError: Cannot read properties of undefined (reading '0')
at isInsideNodeModules (node:internal/util:508:17)
at showFlaggedDeprecation (node:buffer:178:8)
at new Buffer (node:buffer:266:3)
at new module.exports (webpack-internal:///(rsc)/./node_modules/node-int64/Int64.js:65:34)
at DBSQLClient.eval (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:197:111)
at Generator.next (<anonymous>)
at eval (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:31:71)
at new Promise (<anonymous>)
at __awaiter (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:27:12)
at DBSQLClient.openSession (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:196:16)
at eval (webpack-internal:///(rsc)/./app/api/databricks-test/route.ts:25:38)
Error executing query: TypeError: Cannot read properties of undefined (reading '0')
at isInsideNodeModules (node:internal/util:508:17)
at showFlaggedDeprecation (node:buffer:178:8)
at new Buffer (node:buffer:266:3)
at new module.exports (webpack-internal:///(rsc)/./node_modules/node-int64/Int64.js:65:34)
at DBSQLClient.eval (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:197:111)
at Generator.next (<anonymous>)
at eval (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:31:71)
at new Promise (<anonymous>)
at __awaiter (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:27:12)
at DBSQLClient.openSession (webpack-internal:///(rsc)/./node_modules/@databricks/sql/dist/DBSQLClient.js:196:16)
at eval (webpack-internal:///(rsc)/./app/api/databricks-test/route.ts:25:38)
⨯ Error: No response is returned from route handler '/home/slloyd/database_ai_assistant/app/api/databricks-test/route.ts'. Ensure you return a `Response` or a `NextResponse` in all branches of your handler.
at /home/slloyd/database_ai_assistant/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:53611
at async e_.execute (/home/slloyd/database_ai_assistant/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:44747)
at async e_.handle (/home/slloyd/database_ai_assistant/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:54700)
at async doRender (/home/slloyd/database_ai_assistant/node_modules/next/dist/server/base-server.js:1377:42)
at async cacheEntry.responseCache.get.routeKind (/home/slloyd/database_ai_assistant/node_modules/next/dist/server/base-server.js:1599:28)
POST /api/databricks-test 500 in 133ms
The only change made was adding:
webpack: (config) => {
config.resolve.alias.lz4 = false;
return config;
},
to my next.config.js to prevent the following error:
Module not found: Can't resolve '../build/Release/xxhash'```
- 主要语言
- TypeScript
- 星标
- 36
- 派生
- 50
- 平均合并
- 13 小时 46 分钟
- 30 天内合并 PR
- 9
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
databricks/databricks-sql-nodejs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
engineer-bot
难度 2/5 1-3 小时 新手友好度 64/100
databricks/databricks-sql-nodejs#274 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 35/100
查看 databricks/databricks-sql-nodejs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
ontola/atomic-server#1625 ·
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
melgarafael/DeskcommCRM#1451 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
-
bug via-triage
难度 2/5 1-3 小时 新手友好度 78/100
-
bot:ai-assisted component:compact-js status:untriaged
难度 2/5 1-3 小时 新手友好度 84/100
midnightntwrk/midnight-sdk#403 ·