Wrong function on network adapter close?
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
調査の方向性
node_modules/@node-escpos/core/dist/index.cjs の close 実装から始め、issue に示されているアダプター API と比較します。アダプターのクローズに失敗する問題を再現し、その後、flush やエラーハンドリングを壊すことなく、利用可能なメソッドを使ってネットワークアダプターをクローズできることを確認します。この TypeError なしでプリンター接続をクローズできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
First of all, I am just a hobby programmer :)
So basically this is my function.
I have an order which has many order_pos. From the order_pos i can get the corresponding printer (different item different printer)
For your information, i am generating an image which is printed. So i dont have to worry about encoding (like my names show) can print all fonts I want and all sizes I want.
But this is just a side note.
static async printOrder(order: Order) {
PrintingService.splitOrderToPrintRequest(order).then(pr => {
for (let printerInfo of pr) {
(new Network(printerInfo.printerAddress)).open((x, device) => {
PrintingService.getOrderFromIDAndPrinters(order.id, printerInfo.id).then(realOrder => {
if (!realOrder) {
throw new Error("Order is null")
}
try {
// @ts-ignore
const printer = new Printer(device, { encoding: "cp437" })
printer.image(new fickEncodings(realOrder, false).toImage()).then(p => {
p.cut;
p.close()
})
}
catch (err) {
console.log(err)
}
})
})
}
})
}
You can see i am using the inteded way in the function. But i get following error.
node_modules\@node-escpos\core\dist\index.cjs:1167
return new Promise((resolve, reject) => {
^
TypeError: this.adapter.close is not a function
with a console.log(p) in runtime I did see that THE ADAPTER has no close() instead there is an end()
So I tried changing this part
async close(...closeArgs) {
await this.flush();
return new Promise((resolve, reject) => {
this.adapter.close((error) => {
if (error)
reject(error);
resolve(this);
}, ...closeArgs);
});
}
to this:
async close(...closeArgs) {
await this.flush();
return new Promise((resolve, reject) => {
this.adapter.end((error) => {
if (error)
reject(error);
resolve(this);
}, ...closeArgs);
});
}
So i dont know if this is happening to any of you. But with this change its working for me.
plus: i dont have any problems with Too much requests, the printjobs will just wait and print after each other. Magic..
- 主要言語
- TypeScript
- スター
- 1.6k
- フォーク
- 443
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lsongdev/node-escpos のほかの issue
-
[BUG]:オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
lsongdev/node-escpos#447 ·
-
[BUG]: AJCBOSEオープンbug
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
lsongdev/node-escpos#446 ·
-
Capt Bilalオープン
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
lsongdev/node-escpos#443 ·
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
lsongdev/node-escpos#442 · リアクション 2 件 ·
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
lsongdev/node-escpos#441 · コメント 5 件 · リアクション 1 件 ·
lsongdev/node-escpos の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
cockpit-project/cockpit-machines#2835 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cloudflare/kumo#866 ·
メンテナーはふだん 1 日以内に返信
-
area:connector bug
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tester-army/e2e#1015 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信