# Javascript error in Google Perspective API plugin

**URL:** https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732
**Category:** Bug
**Tags:** perspective-api
**Created:** [May 11, 2022, 8:55am UTC](https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732 "2022-05-11T08:55:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [May 11, 2022, 8:55am UTC](https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732/1 "2022-05-11T08:55:51Z")

</div>

We’re seeing this:

```plaintext
TypeError: Cannot read properties of undefined (reading 'finally')
    at n.perspectiveSave (https://REDACTED/assets/plugins/discourse-perspective-api-12d54e93711215e76c0e9e41ddcbaff5276b541b4db8c82f8731e6544a60b4c6.js:1:1041)

```

which seems to come from calling a `finally()` method while the function before that in the chain is not returning anything under various circumstances (there are three `return` statements without arguments in the code).

I am not familiar enough with this specific logic to figure out what should be returned in these places.

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/3/0/d304195b8fa86fe0381ac540cad068db648ec752.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 12, 2022, 1:32am UTC](https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732/2 "2022-05-12T01:32:11Z")

</div>

yeah … this kind of looks like it is intended to be an `async` function and these days we support that.

We will have a look over the next few weeks and get it sorted.

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [June 1, 2022, 4:36am UTC](https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732/12 "2022-06-01T04:36:26Z")

</div>

Hi Richard, just letting you know I am looking into this issue now. Will let you know when I have a fix.

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [June 1, 2022, 6:47am UTC](https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732/13 "2022-06-01T06:47:21Z")

</div>

I think this should fix the issue:

[https://github.com/discourse/discourse-perspective-api/pull/43](https://github.com/discourse/discourse-perspective-api/pull/43)

Let me know if not!

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [June 5, 2022, 10:00pm UTC](https://meta.discourse.org/t/javascript-error-in-google-perspective-api-plugin/226732/14 "2022-06-05T22:00:01Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
