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

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews