← Back to community index
# contributor·Active

! Rushabh | Linux Shill - lib/import-eecircuit-...

lib/import eecircuit engine.ts loads the 21 MB engine by fetching it from the CDN, wrapping the source in a Blob, and calling import(blob:…). Browsers and Bun support importing a blob: URL; Node's ESM loader does not — it throws "Only URLs with a scheme in: file, data, and node a

Started by ! Rushabh | Linux ShillJun 25, 202664 messages

Discussion

Last active 17 days ago · plain text
! Rushabh | Linux Shilloriginal post
lib/import-eecircuit-engine.ts loads the 21 MB engine by fetching it from the CDN, wrapping the source in a Blob, and calling import(blob:…). Browsers and Bun support importing a blob: URL; Node's ESM loader does not — it throws "Only URLs with a scheme in: file, data, and node are supported… Received protocol 'blob:'". So any consumer that runs simulations under Node (e.g. svg.tscircuit.com's Next.js Node runtime) fails. I verified this end-to-end: with a file:// temp-file import the same circuit produces both transient graphs under Node. Therefore svg.tscircuit.com fails https://svg.tscircuit.com/?svg_type=schsim&code=H4sIAJSWPWoAA21S0WqDMBT9leBeWthau64vZQqF7mGwraPrZA%2FCSPVqA5qEmzg6xH9fok2Vrj55z8m5956T1B7jKRwnWh29pQdHKVCTFDJaFZqMxiQIySjmhDzuBcWUoKg04%2FmaKbovIA0tZcgfUWiagxIVJkA4LSGIvWgWe%2BTEmHK2iEytksNXUN%2FNGzJ1YlqWoAG7ijj16tXIHZaIQqABb7LMN19P5EjlwWwjC%2Fr71gmfv182q%2FVQyzkkmgmugrp2KCFSqCWJvUk0IyGZSMbNvNue5pC39PYa3TTd39kDgmJKC3Tbb633DqQ8scj92bzxngmhJTKuDeE%2F%2BJazrU7NNFKTYoaiNHS%2FgD2lhYXOK18IT2FLFHu4iDPafO6u5DmfLZIs%2BxeW2rVzht7dCYQMEIyn7shwlT4Td7OcFiJXrKwKai%2FA9UgrbGv7KkrV99ashHfADw3SUr5fDUglWQJPPGfc%2BuF5Ww%2BHmoHT9pWGY6%2F5A0JngCrYAgAA for ```ts <board routingDisabled> <voltagesource name="V1" voltage="15V" schX={-3} /> <ammeter name="AM1" color="#ff0000" graphDisplayName="I_LOAD" connections={{ pos: ".V1 > .pin1", neg: ".R1 > .pin1", }} /> <resistor name="R1" resistance="2" schX={3} footprint="0402" /> <trace from=".R1 > .pin2" to=".V1 > .pin2" /> <voltageprobe name="VOUT" color="#315cff" connectsTo=".R1 > .pin1" referenceTo=".V1 > .pin2" /> <analogsimulation duration="1ms" timePerStep="100us" spiceEngine="ngspice" /> </board> ``` <@778624824875941908>
! Rushabh | Linux Shill
Shared an attachment
shibo
see how eval does it in runframe?
shibo
actually I noticed no spice simulation works in the docs
shibo
<@452450065941004289>
shibo
it used to work
! Rushabh | Linux Shill
ik
! Rushabh | Linux Shill
the issue is in svg.tscircuit.com
! Rushabh | Linux Shill
<@778624824875941908> this broke it https://github.com/tscircuit/ngspice-spice-engine/pull/22
! Rushabh | Linux Shill
<@809856037376491570>
! Rushabh | Linux Shill
i think we should revert back to package imports
shibo
why? it works in eval, runframe and the cli, we just gotta figure out why it failed in svg.tscircuit.com
! Rushabh | Linux Shill
hmm
! Rushabh | Linux Shill
found the error ``` Compilation Error Simulation failed for"simulation_experiment_0": OnlyURLs with a scheme in: file,data, and node are supported bythe default ESM loader. Receivedprotocol 'blob:' ```
! Rushabh | Linux Shill
- `runframe` works because browser - `cli` works because temp-file import
shibo
<@757706909351411845>
Seve
ok so basically we don't work it NODE right now, we work in browser and bun is that right?
Seve
we might work in newer versions of node- <@452450065941004289> can you replicate locally
Seve
also RE: svg.tscircuit.com, we should preload the ngspice library, i think we might have done this for other libraries, should not be a big deal?
Seve
i.e. svg.tscircuit.com or basically ANY server shouldn't be loading from CDN- it should be a dev dep that is packaged when the server is deployed
! Rushabh | Linux Shill
https://github.com/tscircuit/svg.tscircuit.com/pull/1686 <@809856037376491570>
shibo
did you reproduce the issue locally before implementing the fix?
! Rushabh | Linux Shill
no, inspected how `@tscircuit/eval` does it and copied the logic
! Rushabh | Linux Shill
https://svg-tscircuit-jvr3rmmex-tscircuit.vercel.app/
shibo
we need a repro first, how could we know if this fix worked?
! Rushabh | Linux Shill
https://svg-tscircuit-jvr3rmmex-tscircuit.vercel.app/ i tested it here after deployment
shibo
maybe the issue is not present locally, but only in live deployment
! Rushabh | Linux Shill
yes
shibo
live deployment sometimes is not the same as the preview deployment
shibo
so we must reproduce the issue first
shibo
basically revert your change, see if you get the issue, then push it
! Rushabh | Linux Shill
This is for the curent pr: https://svg-tscircuit-jvr3rmmex-tscircuit.vercel.app/ This is the live deployment link for previous pr: https://svg-tscircuit-1crdasmao-tscircuit.vercel.app/ I tested ```ts <board routingDisabled> <voltagesource name="V1" voltage="15V" schX={-3} /> <ammeter name="AM1" color="#ff0000" graphDisplayName="I_LOAD" connections={{ pos: ".V1 > .pin1", neg: ".R1 > .pin1", }} /> <resistor name="R1" resistance="2" schX={3} footprint="0402" /> <trace from=".R1 > .pin2" to=".V1 > .pin2" /> <voltageprobe name="VOUT" color="#315cff" connectsTo=".R1 > .pin1" referenceTo=".V1 > .pin2" /> <analogsimulation duration="1ms" timePerStep="100us" spiceEngine="ngspice" /> </board> ```
shibo
cool
shibo
<@809856037376491570> https://github.com/tscircuit/svg.tscircuit.com/pull/1686
shibo
<@757706909351411845>
shibo
<@452450065941004289> can you double check it it worked in the live deployment?
! Rushabh | Linux Shill
Yes, Its is not working for svg.tscircuit.com , but it works in https://svg-tscircuit-2mm13se43-tscircuit.vercel.app/ hey <@809856037376491570> is there any difference of environment between these two links in vercel
! Rushabh | Linux Shill
pr:https://github.com/tscircuit/svg.tscircuit.com/pull/1686
Rishabh
The last deployment has failed, run `build` locally to figure out
shibo
<@452450065941004289> what is this commit?
shibo
it's not the latest
! Rushabh | Linux Shill
check this dd0e34c
! Rushabh | Linux Shill
https://github.com/tscircuit/svg.tscircuit.com/actions/runs/28257068828
! Rushabh | Linux Shill
this is newer commit on my test branch
shibo
the thing is that main builds locally, why does it not build in vercel? maybe it does actually build if the snapshot sent by <@809856037376491570> is not from main
! Rushabh | Linux Shill
that one is not from main
! Rushabh | Linux Shill
it also fails locally , its just something i was testing locally, the build started cause i created a pr as i wanted to know how it behaves in prod
! Rushabh | Linux Shill
<@809856037376491570> needs to see the latest build on main branch
Rishabh
what's happening here
Rishabh
Ohh I sent the wrong one?
! Rushabh | Linux Shill
Shared an attachment
Rishabh
yeah, I sent the preview deployment which failed. the main is passing
! Rushabh | Linux Shill
but sch sim is not working for svg.tscircuit.com , but it works in https://svg-tscircuit-2mm13se43-tscircuit.vercel.app/
shibo
you gotta reproduce somehow
shibo
at least now we know it's not a build issue
! Rushabh | Linux Shill
we need to improve the error mesage so we can understand the problem better
shibo
you got a PR?
! Rushabh | Linux Shill
yeah, on it
! Rushabh | Linux Shill
So here is what i found I added better errros https://github.com/tscircuit/svg.tscircuit.com/pull/1688 live link i got for my pr (works perfectly fine): https://svg-tscircuit-6ty0d4oh2-tscircuit.vercel.app/ my vercel deployment of the same branch (errors): https://svg-tscircuit-pxjw8v8l2-rushabh1134s-projects.vercel.app/
! Rushabh | Linux Shill
<@809856037376491570> any idea why this might occur
Seve
Try redeploy? Upgraded node to 24
! Rushabh | Linux Shill
i am already using node 24.x in my deployment
Seve
I updated the svg tscircuit com setting- that is the point
Seve
Now it matches your version, but needs an update to redeploy

Want to add to the conversation?

Reply in Discord so your notes stay connected to the source.
Continue in Discord ↗