Hermanverschooten

Hermanverschooten

I have been using absinthe for a while now, and a couple of months ago we switched from webpack to parcel for our JS bundling. All worked fine for some time, until recently I was notified by one of our clients that the site was no longer working, the wheel kept spinning. I investigated and found a JS error on calling AbsintheSocket.create was logged. The odd thing was that at first, the page still worked in dev, but after an upgrade of some npm stuff, it gave the same error. Initially my guess was something in parcel was causing this and as I had learned that phoenix 1.6 will prefer esbuild. I branched and tried that only to find that the same error still occurs.
Wanting to make sure it is not something else in my code that triggers this error, I cloned the phx_esbuild_demo repo that @josevalim was kind enough to provide. I added the @absinthe/socket npm package, imported it in js/app.js, and it triggers the same error.
I pushed the repo to github (GitHub - Hermanverschooten/phx_esbuild_demo: Test for absinthe socket · GitHub, branch test_absinthe).
Has anyone else run into this error and found a solution? The only reference I find googling has to do with shadow-cljs, but I do not see any solution there.

Showing Posts 1 to 10

Hermanverschooten

Hermanverschooten OP

In the mean time I found that replacing

import * as AbsintheSocket from '@absinthe/socket';

with

const AbsintheSocket = require '@absinthe/socket';

seems to work with esbuild but sadly not with parcel v2.0.0-rc.0.

maartenvanvliet

maartenvanvliet

The phx_esbuild_repo you link to is empty.

Hermanverschooten

Hermanverschooten OP

Oops, code is there now.

mogelbrod

mogelbrod

Having the same problem using parcel@2.0.0-rc.0:

Uncaught (in promise) TypeError: Cannot instantiate an arrow function
    at Object._newArrowCheck [as default] (newArrowCheck.js:7)
    at create1 (create.js:82) - 

The shadow-cljs thread I believe @Hermanverschooten referred to: https://clojurians-log.clojureverse.org/shadow-cljs/2018-08-10
Related github issue: Runtime Error - Cannot instantiate an arrow function · Issue #365 · thheller/shadow-cljs · GitHub

Hermanverschooten

Hermanverschooten OP

This problem is keeping me from upgrading to Phoenix 1.6. With require instead of import it works for esbuild with phx 1.5, but no longer with 1.6. I tried contacting the original creator of absinthe_socket through slack, but to no avail. And my JS knowledge is not good enough to rewrite.

Hermanverschooten

Hermanverschooten OP

Just for information, the require form now works with phoenix as of 1.6.2 :grinning:

neurodynamic

neurodynamic

I had the require fix working for a while with esbuild, but for unrelated reasons I recently started using esbuild’s inject feature and that has brought the Uncaught TypeError: Cannot instantiate an arrow function issue with @absinthe/socket back. When I use the inject option, I see the error, and when I take it out, everything’s fine.

Assuming it was an issue with using arrow function syntax, I even rewrote the @absinthe/socket library and published a version without arrow syntax under @absinthe-noarrows/socket but that doesn’t seem to fix the problem either. I’m completely at a loss. It seems like I either need to find a way to replace process.cwd() without using inject (which is needed for path-browserify), or I can’t use @absinthe/socket.

Anyone have any idea:

  1. How to fix this?
  2. Why using inject would cause it?
  3. Why getting rid of all of the arrow functions in the @absinthe/socket code wouldn’t fix it?
hubertlepicki

hubertlepicki

@neurodynamic do you remember fixing the issue by any chance? I am stuck on the same error too

neurodynamic

neurodynamic

Looking back through my commits, it looks like I eventually just gave up on using the inject feature. Sorry I don’t have better news!

hubertlepicki

hubertlepicki

okay thanks.

I have decided to update the dependencies and migrate to graphql-ws which should work as a drop-in replacement: GraphQLWsLink - Apollo GraphQL Docs

Keep your fingers crossed ;D

Where Next? Top

Trending in Questions Top

Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews