question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose pendingRequests

See original GitHub issue

Clear and concise description of the problem

I’m writing a plugin that collects a list of all the imported sass files and writes them to a single file instead. I can’t write them one by one because sass throws “variable not defined”, so the transform request for the combined file has to be stalled until no other modules are waiting to be resolved.

Suggested solution

Currently I’m using server._pendingRequests which is exactly what I was looking for, but it is a private property so really needs to be documented and exposed in a way that would be compatible with rollup. I proposed using this.pendingRequests in https://github.com/rollup/rollup/issues/4294.

Alternative

No response

Additional context

https://github.com/vuetifyjs/vuetify-loader/blob/274ce9ced8da65107b7544f9cdb2d82d463be313/packages/vite-plugin/src/stylesPlugin.ts

https://github.com/vuetifyjs/vuetify-loader/issues/225 https://github.com/rollup/rollup/issues/4294

Validations

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
sodateacommented, Dec 9, 2021

Some background:

So now I’m using it in vite-jest too. Seems worth exposing to me. We’ll discuss it at the next team meeting.

1reaction
bluwycommented, Aug 28, 2022

I actually had to this something like this for my plugin, and thanks to your issue and code @KaelWD I implemented something similar like so:

// wait for all modules loaded before getting the entry ids
const seen = new Set()
let modulesToWait = []
do {
  modulesToWait = []
  for (const id of this.getModuleIds()) {
    if (seen.has(id)) continue
    seen.add(id)
    if (id.startsWith('\0')) continue
    const info = this.getModuleInfo(id)
    if (info?.isExternal) continue
    modulesToWait.push(this.load({ id }).catch(() => {}))
  }
  // TODO: timeout if too long
  await Promise.all(modulesToWait)
} while (modulesToWait.length > 0)

Besides the TODO, and that I’ve only tested it on a small project, it seems to be working well. I suppose this would work for Rollup too and I hope we can find a trick that works in both without Vite exposing pendingRequests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expose pendingRequests · Issue #4294 · rollup/rollup - GitHub
I'm writing a plugin that needs to make modifications to a file based on other files in the project. In vite I'm using...
Read more >
$http - AngularJS: API
The $http API is based on the deferred/promise APIs exposed by the $q service. ... Array of config objects for currently pending requests....
Read more >
Exposing a Python function — Dataiku DSS 11 documentation
You can expose any Python function as a endpoint on the API node. ... But when all pending requests have been completed, the...
Read more >
exposed package - github.com/thesyncim/exposed - Go Packages
README ¶. Exposed - minimal high performant reflectionless RPC Server ... PendingRequests returns the number of pending requests at the moment.
Read more >
Circuit breakers (proto) - Envoy Proxy
(UInt32Value) The maximum number of pending requests that Envoy will allow to the upstream cluster. If not specified, the default is 1024.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found