Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String response causes TypeError in getEvents #45

Open
itsfolf opened this issue Jan 15, 2024 · 1 comment
Open

String response causes TypeError in getEvents #45

itsfolf opened this issue Jan 15, 2024 · 1 comment

Comments

@itsfolf
Copy link

itsfolf commented Jan 15, 2024

I am not entirely sure how, but it seems to be possible for the axios res.data to be a string, despite the content-type being correctly set to json, causing the snippet below to error with TypeError: n.forEach is not a function. This happens with both aw-server and aw-server-rust, and only in Firefox.

const events = await this._get("/0/buckets/" + bucketId + "/events", {
params,
});
events.forEach((event: IEvent) => {
event.timestamp = new Date(event.timestamp);
});

private async _get(endpoint: string, params: object = {}) {
return this.req
.get(endpoint, { ...params, signal: this.controller.signal })
.then((res) => (res && res.data) || res);
}

@itsfolf
Copy link
Author

itsfolf commented Jan 15, 2024

After some further investigation, it seems like the error is caused by invalid json which axios decides to treat as a string, I am not able to share the full payload as it includes an entire day of private information, but I was able to narrow it down to the following section of events:

[{"id":21221,"timestamp":"2024-01-12T07:00:20.506Z","duration":0.0,"data":{"app":"Telegram.exe","title":"Furmeet Group @ Folf ᗢ�:04:40.705Z","duration":5.07,"data":{"app":"firefox.exe","title":"Commits · master · min / cshare · GitLab — Mozilla Firefox"}},{"id":22074,"timestamp":"2024-01-12T05:04:33.605Z","duration":6.083,"data":{"app":"firefox.exe","title":"min / cshare · GitLab — Mozilla Firefox"}},{"id":22075,"timestamp":"2024-01-12T05:04:31.576Z","duration":1.012999999,"data":{"app":"firefox.exe","title":"min · GitLab — Mozilla Firefox"}}]

Given this information, perhaps this issue is better well suited for aw-server or aw-server-rust, but as I'm not sure of the root cause I will leave it here for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant