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

Requests on error catch was getting added in fullfilled requests #210

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-deers-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mexit-webapp': patch
---

[FIX] Requests getting fullfilled in runBatch even on throwing error.
12 changes: 7 additions & 5 deletions apps/webapp/src/Hooks/API/useNamespaceAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ export const useNamespaceApi = () => {
const requestData = { time: Date.now(), method: 'GET' }

fulfilled.forEach((node) => {
const { rawResponse, nodeid } = node
setRequest(apiURLs.getNode(nodeid), { ...requestData, url: apiURLs.getNode(nodeid) })
const content = deserializeContent(rawResponse.data)
const metadata = extractMetadata(rawResponse) // added by Varshitha
updateFromContent(nodeid, content, metadata)
if (node) {
const { rawResponse, nodeid } = node
setRequest(apiURLs.getNode(nodeid), { ...requestData, url: apiURLs.getNode(nodeid) })
const content = deserializeContent(rawResponse.data)
const metadata = extractMetadata(rawResponse) // added by Varshitha
updateFromContent(nodeid, content, metadata)
}
})
}
}
Expand Down
18 changes: 6 additions & 12 deletions apps/webapp/src/Workers/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import axios from 'axios'
import { customAlphabet } from 'nanoid'
import { expose } from 'threads/worker'

import { apiURLs, runBatch, mog, extractMetadata } from '@mexit/core'
import { apiURLs, runBatch } from '@mexit/core'

import { deserializeContent } from '../Utils/serializer'
import { WorkerRequestType } from '../Utils/worker'

const nolookalikes = '346789ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrtwxyz'
Expand All @@ -26,16 +25,11 @@ const initializeClient = (authToken: string, workspaceID: string) => {

const getNodeAPI = async (nodeid: string, isShared = false) => {
const url = isShared ? apiURLs.getSharedNode(nodeid) : apiURLs.getNode(nodeid)
return client
.get(url)
.then((d: any) => {
if (d) {
return { rawResponse: d.data, nodeid }
}
})
.catch((e) => {
console.error(`MexError: Fetching nodeid ${nodeid} failed with: `, e)
})
return client.get(url).then((d: any) => {
if (d) {
return { rawResponse: d.data, nodeid }
}
})
}

const getSnippetAPI = async (id: string) => {
Expand Down
2 changes: 0 additions & 2 deletions libs/core/src/Utils/batchPromise.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { mog } from './mog'

const BATCH_SIZE = 6

const batchArray = (array: any[], batchSize: number): any[][] => {
Expand Down