fix: apiでネイティブfetchを格納する際に無名関数でラップするように #29

Merged
tamaina merged 3 commits from fix-fetch into develop 2021-09-21 10:45:07 +00:00
tamaina commented 2021-09-21 04:43:53 +00:00 (Migrated from github.com)

What

apiにブラウザネイティブのfetchを格納する際、そのまま代入せず無名関数でラップしたものを代入するように

Why

特にChromiumでは、ネイティブ関数をそのまま変数に代入して使おうとするとIllegal invocationエラーが発生する。

See https://github.com/misskey-dev/misskey/pull/7667#issuecomment-923162458

# What apiにブラウザネイティブのfetchを格納する際、そのまま代入せず無名関数でラップしたものを代入するように # Why 特にChromiumでは、ネイティブ関数をそのまま変数に代入して使おうとするとIllegal invocationエラーが発生する。 See https://github.com/misskey-dev/misskey/pull/7667#issuecomment-923162458
codecov[bot] commented 2021-09-21 04:44:49 +00:00 (Migrated from github.com)

Codecov Report

Merging #29 (e1bf59c) into develop (f278390) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #29      +/-   ##
===========================================
+ Coverage    94.70%   94.72%   +0.02%     
===========================================
  Files            2        2              
  Lines          434      436       +2     
  Branches        51       52       +1     
===========================================
+ Hits           411      413       +2     
  Misses          23       23              
Impacted Files Coverage Δ
src/api.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f278390...e1bf59c. Read the comment docs.

# [Codecov](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report > Merging [#29](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (e1bf59c) into [develop](https://codecov.io/gh/misskey-dev/misskey.js/commit/f2783900127afd103ae485ab1cd0f00aff2fcdd9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (f278390) will **increase** coverage by `0.02%`. > The diff coverage is `100.00%`. [![Impacted file tree graph](https://codecov.io/gh/misskey-dev/misskey.js/pull/29/graphs/tree.svg?width=650&height=150&src=pr&token=PbrTtk3nVD&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) ```diff @@ Coverage Diff @@ ## develop #29 +/- ## =========================================== + Coverage 94.70% 94.72% +0.02% =========================================== Files 2 2 Lines 434 436 +2 Branches 51 52 +1 =========================================== + Hits 411 413 +2 Misses 23 23 ``` | [Impacted Files](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/api.ts](https://codecov.io/gh/misskey-dev/misskey.js/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2FwaS50cw==) | `100.00% <100.00%> (ø)` | | ------ [Continue to review full report at Codecov](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Last update [f278390...e1bf59c](https://codecov.io/gh/misskey-dev/misskey.js/pull/29?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).
syuilo (Migrated from github.com) reviewed 2021-09-21 07:18:53 +00:00
@ -50,1 +49,4 @@
// ネイティブ関数をそのまま変数に代入して使おうとするとChromiumではIllegal invocationエラーが発生するため、
// 環境で実装されているfetchを使う場合は無名関数でラップして使用する
this.fetch = opts.fetch || ((...args) => fetch(...args));
}
syuilo (Migrated from github.com) commented 2021-09-21 07:18:53 +00:00

特にChromiumでは、ネイティブ関数をそのまま変数に代入して使おうとするとIllegal invocationエラーが発生する。

ことをコメントとかで残しておくと親切かも

> 特にChromiumでは、ネイティブ関数をそのまま変数に代入して使おうとするとIllegal invocationエラーが発生する。 ことをコメントとかで残しておくと親切かも
tamaina (Migrated from github.com) reviewed 2021-09-21 10:37:07 +00:00
@ -50,1 +49,4 @@
// ネイティブ関数をそのまま変数に代入して使おうとするとChromiumではIllegal invocationエラーが発生するため、
// 環境で実装されているfetchを使う場合は無名関数でラップして使用する
this.fetch = opts.fetch || ((...args) => fetch(...args));
}
tamaina (Migrated from github.com) commented 2021-09-21 10:37:07 +00:00

こんな感じ?

こんな感じ?
syuilo commented 2021-09-21 10:45:10 +00:00 (Migrated from github.com)

👍

👍
This repo is archived. You cannot comment on pull requests.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: norm/foundkey.js#29
No description provided.