Commit 200d212
committed
fixes the
in js, any object can be thrown. that is why the `catch` block `error` variable has type `unknown` in typescript. in optimizely, there are a few catch blocks where the error variable is directly logged as message. in the logger, the type of the public named logging functions is `string | Error` which is not correct since it could actually be any type. if it is an object that is not an instance of type Error, this will cause a throw in `internalLog -> format -> sprintf` because sprintf is calling `.replace` on the message, which throws with `e.replace is not a function`. we have seen this exact error a lot in production. so logging causes a throw which causes createInstance to fail, causing further issues.
this PR fixes the issue by converting non-string and non-Error log messages to string first.
fixes #719e.replace is not a function error happening on production in Firefox during createInstance1 parent ac7e86a commit 200d212
1 file changed
+13
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | 272 | | |
274 | 273 | | |
275 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
276 | 286 | | |
277 | 287 | | |
278 | 288 | | |
| |||
0 commit comments