TypeError: Cannot read properties of undefined (reading '0') using client.openSession();
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- next.js, node.js, sql, typescript
- Lĩnh vực
- backend, build-system
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi từ app/api/databricks-test/route.ts với webpack alias trong next.config.js, sau đó so sánh với examples/usage.js. Theo dõi đường đi của openSession qua @databricks/sql và node-int64/Int64.js, đồng thời xác minh rằng workaround lz4 không còn gây ra TypeError. Được xem là hoàn tất khi session mở thành công, truy vấn ví dụ trả về kết quả và mọi nhánh của route-handler đều trả về một response.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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'```
- Ngôn ngữ chính
- TypeScript
- Star
- 36
- Fork
- 50
- Merge trung bình
- 13 giờ 46 phút
- Pull request đã merge (30 ngày)
- 9
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của databricks/databricks-sql-nodejs
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Docs folder deleted in 1.8.4 Đang mởengineer-bot
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
databricks/databricks-sql-nodejs#274 · 1 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Tất cả issue của databricks/databricks-sql-nodejs
Issue tương tự
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100