Skip to content

Connect slows down when clicking through many devices/routes #456

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

Open
sshane opened this issue Apr 3, 2025 · 7 comments
Open

Connect slows down when clicking through many devices/routes #456

sshane opened this issue Apr 3, 2025 · 7 comments
Milestone

Comments

@sshane
Copy link
Contributor

sshane commented Apr 3, 2025

With Fast 3G network requests pile up and the FPS plummets on desktop. Old connect feels faster, that could be because old connect caches more, but we probably can also just cancel old requests to speed this up another way

@sshane sshane added this to the 1.0 milestone Apr 3, 2025
@greatgitsby
Copy link
Contributor

solidjs/solid#1258 :-/

@incognitojam
Copy link
Member

solidjs/solid#1258 :-/

I don't think you want to abort the resource, you can just abort the fetch, and when the fetch throws the resource will go to the errored state (if it hasn't already been cleaned up)

@greatgitsby
Copy link
Contributor

it would be more convenient if the signal handled it, otherwise we'd need some invasive changes to our request handling

perhaps a generic createAbortableResource could hook into the reactive system and abort the resource fn when the input signal changed 🤔

@greatgitsby
Copy link
Contributor

@incognitojam
Copy link
Member

Could do something like this

import { createResource, onCleanup, type ResourceOptions, type ResourceReturn } from 'solid-js'

// copied the types from https://docs.solidjs.com/reference/basic-reactivity/create-resource#note-for-typescript-users
function createAbortableResource<T, U>(
  source: U | false | null | (() => U | false | null),
  fetcher: (source: U, signal: AbortSignal, info: { value: T | undefined; refetching: boolean | unknown }) => T | Promise<T>,
  options?: ResourceOptions<T, U>,
): ResourceReturn<T> {
  return createResource(
    source,
    (source, info) => {
      const controller = new AbortController()
      onCleanup(() => controller.abort())  // trigger abort signal on cleanup (when source changes)
      return fetcher(source, controller.signal, info)
    },
    options,
  )
}

Using it like this (but we'd have to tweak our api methods...)

import { fetcher } from '~/api'
import type { Device } from '~/api/types'

const getDevice = (dongleId: string, signal?: AbortSignal) =>
  fetcher<Device>(`/v1.1/devices/${dongleId}/`, { signal })

const props = { dongleId: 'abc' }
const [data] = createAbortableResource(() => props.dongleId, getDevice)

@greatgitsby
Copy link
Contributor

yeah this is what i was thinking, too

@greatgitsby
Copy link
Contributor

greatgitsby commented Apr 9, 2025

doesn't feel bad on 3G with #539 except video never loads. old connect is the same way

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

3 participants