経験は何よりも饒舌

10年後に真価を発揮するかもしれないブログ 

Notes on the breaking change that occurred in Axios v0.25.0

Axios v0.25.0 was released on January 18, 2022.

One of the breaking changes is adding error handling when missing url, which returns an Error if the Request Config url specified in the argument is Falsy.
This was introduced to clarify bugs and errors, but there have been issues where the URL is intentionally set to Falsy, such as when using the baseURL of Request Config or when sending a request to GraphQL.

Some say that in order to upgrade to Node14, need the aborted event handler that was added in the same release, but can't upgrade Axios because of this change, and I, as the implementor of this breaking change, think this is an issue that should be addressed quickly.

This issue proposes the following fixes: "Allow empty strings", "Create a new option", and "Change the location of the error handling".
Maintainer jasonsaayman answers with 「It would be nice to keep everyone happy, so I would like to give this some more thought come up with a solid solution to this, I will revert back after the weekend with my ideas.」


PS January 27, 2022.
PR to be reverted is merged and will be released soon.
https://github.com/axios/axios/issues/4407#issuecomment-1022894805

PS Feburary 18, 2022.
Fix has already released.
Release v0.26.0 · axios/axios · GitHub

Axios v0.25.0 で生じた breaking change の注意点

English version:
Notes on the breaking change that occurred in Axios v0.25.0 - 経験は何よりも饒舌


2022年1月18日に Axios v0.25.0がリリースされました

その中の breaking change の1つに Adding error handling when missing url があります。
これは、引数で指定するRequest ConfigurlFalsyである場合にErrorを返すという変更です。
バグやエラーの内容を明確にすることを目的に導入されましたが、Request ConfigのbaseURLを活用する際や、GraphQLにリクエストを送る際など、意図的にFalsyにしている場合があるというissueが立てられています

Node14にアップグレードするために、同じリリースで追加されたaborted event handlerが必要だが、この変更のためにAxiosをアップグレードできないという発言もあり、このbreaking changeの実装者である私も速やかに対応すべき問題だと考えています。

このissueでは「空文字列を許容する」、「新たにoptionを作る」、「エラー処理の場所を変える」という修正案が出されており、メンテナーである@jasonsaaymanは
「It would be nice to keep everyone happy, so I would like to give this some more thought come up with a solid solution to this, I will revert back after the weekend with my ideas.」
と回答している状態です。

2022/1/27 追記
revertするPRがマージされ、もうじきリリースされます
https://github.com/axios/axios/issues/4407#issuecomment-1022894805

2022/2/18 追記
修正がリリースされています
Release v0.26.0 · axios/axios · GitHub

denodrivers/deno_mongo で作った my good first issue

この記事はDeno Advent Calendar 2021の19日目です。

deno_mongo で取り組んだ my good first issue を紹介したいと思います。

README.mdに情報を足す

リンクに飛んだ方がわかりやすいと思ったのでそうしました。
docs: Improve README by wafuwafu13 · Pull Request #294 · denodrivers/mongo · GitHub

フォーマットを統一する

varが使われているなど、VSCode上で警告の出ている箇所がちらほらあったので、CIでdeno lintを走らせるようにしました。
chore: Run `deno lint` in CI by wafuwafu13 · Pull Request #298 · denodrivers/mongo · GitHub

TODOコメントを拾う

TODO: add test casesを拾いました。
test(02_connect): Add `runCommand` test by wafuwafu13 · Pull Request #295 · denodrivers/mongo · GitHub

非推奨のAPIを使わない

非推奨になったassertThrowsAsyncが使われていたので書き換えました。
chore: `assertThrowsAsync` is deprecated by wafuwafu13 · Pull Request #313 · denodrivers/mongo · GitHub

テストの方法を改善

MongoのCURD操作のテストをしているファイルがあるのですが、最初に実行されるテストから最後まで同じコレクションが使われており、テスト間に依存関係がある状態でした。
その状態では、最後の方にあるテストを読もうとしたとき、最初の方のテストで何がinsertされたのかを順に追っていかないといけないので辛いです。
そのため、各テストの実行後のコレクションの中身をコメントで追記するという作業をしました。
chore(test/03_curd): Improve readability by wafuwafu13 · Pull Request #302 · denodrivers/mongo · GitHub
しかし、テストを追加する際にコメントも編集しないといけなくなる、そもそも依存関係をなくした方が良いという議論になりました。
それはそうだと思ったので、各テストの実行後にコレクションの中身を削除する関数を用意し、依存関係のないテストを新たに書きました。
test(03_curd): Write tests that do not depend on each other by wafuwafu13 · Pull Request #311 · denodrivers/mongo · GitHub




機能の追加やバグ修正はしていませんが、それ以外にもできることが結構ある場合があります。
good first issue といえども、コードの全体像を把握した上での good first issue なので、まずは自分なりの my good first issue に取り掛かるのもありかもしれません。

DBスペシャリスト試験不合格記

令和3年度秋期のデータベーススペシャリスト試験を受けた。

結果


動機

時間があった。
基本情報も応用情報も受けてないけど、高度試験は面白そうだったから、ちょうど時期が合ったDBを受けてみた。

対策

受ける前からバックエンドの経験は積んでいたので元々読んでいた本があった。

対策を進める上で『SQLアンチパターン』をさらっと参照することが1回あるかないかくらい、『実践ハイパフォーマンスMySQL』はモニターのかさ増しのままだった。

この本をメインに対策を進めていった。

午前Iと午前IIで採点がストップするのはどうしても避けたかったから、本からダウンロードできる過去問でかなり対策していた。

午前I 12年
午前II 8年

午後はそれぞれ5年分くらいやった。

感想

午前IIはかなり手応えがあったけどギリギリだったのが意外だった。
午後Iは時間が足りなくなってしまった。
空白が結構あったのに49点あったのが意外。
午後IIは時間に余裕があって、きちんとカラム名入れて線をひけていた記憶があるので、採点まで到達できなくて残念。


合格しようというモチベーションはなくてもう受けないけど、受けて損はなかったと思う。
特に正規形に関する部分をあらためて深められたのと、既存に組み立てられた割と大規模なリレーションを理解して解いていくのは実践的でよかった。
高度試験の雰囲気を知れたし、午前Iの免除があるから、次はネットワークスペシャリストを受けようと思う。

Architecture of nodejs/node and denoland/deno_std/node

I contribute to denoland/deno_std as a hobby, and I've been looking at denoland/deno_std/node a lot, so I thought I'd take a quick look at the architectural differences between the nodejs/node and denoland/deno_std/node APIs at this point in time (2021/12/16).

Where to implement the API

nodejs/node

It is implemented in node/lib.
Using Query string as an example, the logic is implemented in node/lib/querystring.js and exported at here.
In addition, internal code that does not need to be exported is implemented in node/lib/internal.
In Query string, functions such as encordStr are exported, and imported at node/lib/querystring.js.

denoland/deno_std

It is implemented in deno_std/node.
APIs that are compatible with the logic exported in nodejs/node/lib/querystring.js in deno_std/node/querystirng.ts are exported here.
Also, in deno_std/node/internal, an implementation equivalent to nodejs/node/lib/internal has been created.

Implementation Language

nodejs/node

It is implemented in JavaScript and C++.
Using URL as an example, some C++ code is called by the internalBinding in JavaScript implementations such as node/lib/url.js and node/lib/internal/url.js.
For example, the domainToASCII implementation is in node/src/node_url.cc.
Incidentally, I was wondering why it is not implemented in JavaScript, and asked Why domainToASCII is written by C++ not JS? in the help repository, and got the answer "for perf reasons".
Also, primordials are used in many places.
You can read more about primordials in the suggestions around prototype pollution and primordials.js(Japanese article).

denoland/deno_std

It is implemented in JavaScript and TypeScript.
For example, Query string is implemented in querystring.ts, and Buffer is implemented in node/buffer.js, and node/buffer.d.ts is specified in @deno-types of node/buffer.ts.
The equivalent of Node's internalBinding is implemented by TypeScript in node/internal_binding.
The primordials are implemented in denoland/deno, but not in denoland/deno_std.

Tests

nodejs/node

It can be found in node/test.
For example, URL testing is implemented in node/test/parallel/test-url-*.js.
The execution method and other information is summarized in pull-requests.md.

denoland/deno_std

In node/_tools/config.json, specify the file name of the test in nodejs/node/test, retrieve it in node/_tools/setup.ts, and place it in node/_tools/suites.
The execution method and other information is summarized in node/README.md.

nodejs/node と denoland/deno_std/node のアーキテクチャ

English version: Architecture of nodejs/node and denoland/deno_std/node - 経験は何よりも饒舌


この記事は Advent Calendar 2021 Deno の16日目です。
趣味でdenoland/deno_stdにコントリビュートしており、特に denoland/deno_std/node をよく見ているので、nodejs/nodedenoland/deno_std/node の現時点(2021/12/16)でのNode APIにまつわるアーキテクチャの違いをざっくり書いていこうと思います。

APIの実装場所

nodejs/node

node/libに実装されています。
Query stringを例にすると、node/lib/querystring.jsでロジックが実装されていて、ここでexportされています。
また、exportする必要のない内部のコードがnode/lib/internalで実装されています。
Query stringではencordStrなどの関数がexportされてnode/lib/querystring.jsでimportされています。

denoland/deno_std

deno_std/nodeに実装されています。
deno_std/node/querystirng.tsnodejs/node/lib/querystring.jsでexportされているロジックと互換性のあるAPIここでexportされています。
また、deno_std/node/internalで、nodejs/node/lib/internal相当の実装がされています。

Implementation Language

nodejs/node

JavaScriptC++で実装されています。
URLを例にすると、node/lib/url.jsnode/lib/internal/url.jsといったJavaScriptの実装の中で一部、internalBindingによってC++のコードが呼び出されています。
例えばdomainToASCIIの実装はnode/src/node_url.ccにされています。
ちなみに、なぜJavaScriptで実装されていないのかと疑問を持ち、helpレポジトリでWhy domainToASCII is written by C++ not JS?と伺ったところ、for perf reasonsという回答をいただきました。
また、各所でprimordialsが使われています。
primordialsについてはプロトタイプ汚染周りの提案と primordials.jsが詳しいです。

denoland/deno_std

JavaScriptとTypeScriptで実装されています。
例えばQuery stringはquerystring.tsで実装されていますが、Buffernode/_buffer.jsで実装されており、node/buffer.ts@deno-typesnode/_buffer.d.tsが指定されています。
NodeのinternalBindingに相当する実装はnode/internal_bindingでTypeScriptにより実装されています。
primordialsは、denoland/denoには導入されていますが、denoland/deno_stdには導入されていません。

テスト

nodejs/node

node/testにあります。
例えばURLのテストはnode/test/parallel/test-url-*.jsで実装されています。
実行方法などはpull-requests.mdにまとまっています。

denoland/deno_std

node/_tools/config.jsonで、nodejs/node/testにあるテストのファイル名を指定し、node/_tools/setup.tsで取得し、node/_tools/suitesに配置しています。
実行方法などはnode/README.mdにまとまっています。

Scrapboxを使って技術書を真剣に読む


23卒のエンジニア職志望向けAdvent Calendar Advent Calendar 2021の13日目です。

学生時代の行動指針としてインフラに長期間触れてみたいという思いがあり、いろいろ本を読んだりして準備していたのですが、いざインフラに常に触れられる状態になると、読んだ内容を詳細に思い出せないことに気がつきました。
自分の強みである、既存のコードを読む力はアプリケーションを開発するときにもインフラを構築するときにも役立っていますが、概念の習得、例えばアプリケーションでいうとDOMとは、インフラでいうとDNSとは、とかいう部分は長期間触れ続けないと忘れる、自分の場合は特にインフラの概念を忘れる傾向にあります。しかもそれは既存のコードを読む力の前提となる部分であるから、確固とした知識を入れておかないといけないと感じました。
技術書は一回読むだけではなく繰り返し読むことが多いですが、早く読み終わりたいという意識が無意識に働き、重要な概念を読み飛ばしていることが早期の忘却につながっているのではないかという仮説を立て、今一度じっくり技術書を真剣に読みなおすという方針を立てました。
そこで用いたのがScrapboxで、まずは『ネットワークはなぜつながるのか』の重要な部分を書き起こしながら読むことと、登場した概念をリンクにすることを実践しています。

今のところかなり効果を感じています。
読んだ内容を脳内で整理してからまとめて書くことにより理解が深まるし、後で追いやすいです。また、読み流して無理矢理前に進むことがなくなりました(1周目に関しては読み流してでも本の全体像を把握することは有用だと思うが、2周目、3周目で読み流すのは避けたい)。
学部時代に独学で習得すべきジャンルは既に全て一回は読み流しているはずなので、これからはじっくりまとめながら確固とした知識を吸収し続けたいです。